Declaration Area

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Group,

I'm familiar with VB, but this question applies to C#.

I'm doing walk thru in C# and it ask me to declare a new dataset named
authors.

// C#
DataSet dsAuthors = new DataSet("authors");

I'm not sure where to put it.

Also, I'm pretty sure that there are different scope on where i declare this
dataset, but when past the information above, the first word "DataSet" gets
underline like an error: A namespace does not directly contain members such
as fields or method.

Please explain to what that ment.

Thanks in advance.
 
Ronin,

Basically, you have to define everything in a class (in VB, you could do
this in a module, I believe).

So in C#, you have to wrap the dataset variable in a class, and have it
either be static or instance. Then, you can access it in the appropriate
scope.

Hope this helps.
 
Thanks so much... it does helps alot.


Ronin

Nicholas Paldino said:
Ronin,

Basically, you have to define everything in a class (in VB, you could do
this in a module, I believe).

So in C#, you have to wrap the dataset variable in a class, and have it
either be static or instance. Then, you can access it in the appropriate
scope.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Ronin said:
Group,

I'm familiar with VB, but this question applies to C#.

I'm doing walk thru in C# and it ask me to declare a new dataset named
authors.

// C#
DataSet dsAuthors = new DataSet("authors");

I'm not sure where to put it.

Also, I'm pretty sure that there are different scope on where i declare
this
dataset, but when past the information above, the first word "DataSet"
gets
underline like an error: A namespace does not directly contain members
such
as fields or method.

Please explain to what that ment.

Thanks in advance.
 
Ronin said:
I'm familiar with VB, but this question applies to C#.

I'm doing walk thru in C# and it ask me to declare a new dataset named
authors.

// C#
DataSet dsAuthors = new DataSet("authors");

I'm not sure where to put it.

Also, I'm pretty sure that there are different scope on where i declare this
dataset, but when past the information above, the first word "DataSet" gets
underline like an error: A namespace does not directly contain members such
as fields or method.

Please explain to what that ment.

It means that you're trying to declare the variable directly in the
namespace, rather than as a local variable within a method, or an
instance variable within a class.
 
Back
Top