D'Jok
D'Jok

Reputation: 51

Issue with Google translate

I'm creating application that translates text. I got most of the code right but somehow I'm stuck on this:

using System.Windows.Forms;
using Google.API.Translate;
using System.Speech.Synthesis;
using System.Speech.Recognition;

namespace translator
{
    public partial class Form1 : Form
    {
        private List listLanguage = Language.TranslatableCollection.ToList();
        private List translatableLanguage = new List();
        private SpeechSynthesizer synth = new SpeechSynthesizer();

        public Form1()
        {
        }
    }
}

Where 'List' up there gives me an error but I don't know what's wrong. I'm working in VS 2012 in C#.

Upvotes: 1

Views: 580

Answers (4)

Rayet
Rayet

Reputation: 298

You have to specify what kind of list you want to use. Especially if you are working on Generic.List. For example:

private List<YourType> field = new List<YourType>();

Read more about difference between generic and collections:

http://msdn.microsoft.com/en-us/library/6sh2ey19%28v=vs.110%29.aspx

http://msdn.microsoft.com/en-us/library/ybcx56wz.aspx

Upvotes: 0

RoughPlace
RoughPlace

Reputation: 1121

he List requires a Type.

i would find what type you are expecting and add that to the code.

i.e.

private List<Language> listLanguage = Language.TranslatableCollection.ToList();
private List<Language> translatableLanguage = new List<Language>();

Upvotes: 1

Burrhus
Burrhus

Reputation: 156

System.Collections.List requires the type of the content.. Like this

Private List<string> mylist = new List<string>()

if you are referring to a list in another namespace, provide the namespace as well

Upvotes: 0

Abbas
Abbas

Reputation: 14432

There is no such class as List. I think you mean the List<T> class in the System.Collections.Generic namespace. This means your instantiation will look like this:

//'Translatable' is just a dummy class name
private List<Translatable> listLanguage = Language.TranslatableCollection.ToList();

Upvotes: 0

Related Questions