Another VB to C# Question

T

Tina

As I continue to convert a large vb.net project to C# is am now seeing that
the namespaces are different. I never expected this.

For instance in vb I use System.Drawing.Color so I can say red yellow, etc.

But in C# Color is not in Drawing! Where is it?

Are there any docs on differences in the namespaces?

Thanks,
T
 
N

Nicholas Paldino [.NET/C# MVP]

Actually, I think that it does. I believe that VB does not require the
enumeration type or type to be declared before using a member from an
enumeration or a static member, so you could use statements like "Red",
"Yellow", etc, etc.

In C#, you need to say "Colors.Red", "Colors.Yellow", etc, etc.

Hope this helps.
 
T

Tina

Yes. That's it. the vb imports statement is not at all like the C# using
statement. C# using statements can only have namespaces. Seems to be
another unnecessary difference.
Thanks,
T

Nicholas Paldino said:
Actually, I think that it does. I believe that VB does not require the
enumeration type or type to be declared before using a member from an
enumeration or a static member, so you could use statements like "Red",
"Yellow", etc, etc.

In C#, you need to say "Colors.Red", "Colors.Yellow", etc, etc.

Hope this helps.


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

Peter Bromberg said:
System.Drawing is a Framework Class. Has nothing to do with VB.NET vs
C#.

http://msdn.microsoft.com/library/d...ef/html/frlrfsystemdrawingcolorclasstopic.asp

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
 
H

Hareth

this might also help you convert
http://www.developerfusion.co.uk/utilities/convertvbtocsharp.aspx

Tina said:
Yes. That's it. the vb imports statement is not at all like the C# using
statement. C# using statements can only have namespaces. Seems to be
another unnecessary difference.
Thanks,
T

in
message news:[email protected]...
Actually, I think that it does. I believe that VB does not require
the
enumeration type or type to be declared before using a member from an
enumeration or a static member, so you could use statements like "Red",
"Yellow", etc, etc.

In C#, you need to say "Colors.Red", "Colors.Yellow", etc, etc.

Hope this helps.


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

message
System.Drawing is a Framework Class. Has nothing to do with VB.NET vs
C#.

http://msdn.microsoft.com/library/d...ef/html/frlrfsystemdrawingcolorclasstopic.asp

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




:

As I continue to convert a large vb.net project to C# is am now seeing
that
the namespaces are different. I never expected this.

For instance in vb I use System.Drawing.Color so I can say red yellow,
etc.

But in C# Color is not in Drawing! Where is it?

Are there any docs on differences in the namespaces?

Thanks,
T
 
G

Guest

You should have tried it first - that on-line converter (and all the other
on-line converters) do not handle this situation.

e.g., the following VB code:
imports System.Drawing.Color
class testclass
sub testsub()
x = Red
end sub
end class

should convert to (obtained from Instant C#):
using System.Drawing;
internal class testclass
{
public void testsub()
{
x = Color.Red;
}
}

The on-line converter you mentioned ignores the difference between the VB
Imports and C# using directive.

--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter & VB to C++ converter
Instant J#: VB to J# converter



Hareth said:
this might also help you convert
http://www.developerfusion.co.uk/utilities/convertvbtocsharp.aspx

Tina said:
Yes. That's it. the vb imports statement is not at all like the C# using
statement. C# using statements can only have namespaces. Seems to be
another unnecessary difference.
Thanks,
T

in
message news:[email protected]...
Actually, I think that it does. I believe that VB does not require
the
enumeration type or type to be declared before using a member from an
enumeration or a static member, so you could use statements like "Red",
"Yellow", etc, etc.

In C#, you need to say "Colors.Red", "Colors.Yellow", etc, etc.

Hope this helps.


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

message
System.Drawing is a Framework Class. Has nothing to do with VB.NET vs
C#.

http://msdn.microsoft.com/library/d...ef/html/frlrfsystemdrawingcolorclasstopic.asp

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




:

As I continue to convert a large vb.net project to C# is am now seeing
that
the namespaces are different. I never expected this.

For instance in vb I use System.Drawing.Color so I can say red yellow,
etc.

But in C# Color is not in Drawing! Where is it?

Are there any docs on differences in the namespaces?

Thanks,
T
 
C

Claes Bergefall

Nope, you can't say "Red", "Yellow" etc. VB.NET needs Color.Red,
Color.Yellow etc just like C#
The reason you often don't need to type the whole namespace is because
VB.NET by default imports a bunch of namespaces (check the project
settings), System.Drawing being one of them. If you remove that import from
your project settings you would need to use System.Drawing.Color.Red etc

/claes

Nicholas Paldino said:
Actually, I think that it does. I believe that VB does not require the
enumeration type or type to be declared before using a member from an
enumeration or a static member, so you could use statements like "Red",
"Yellow", etc, etc.

In C#, you need to say "Colors.Red", "Colors.Yellow", etc, etc.

Hope this helps.


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

Peter Bromberg said:
System.Drawing is a Framework Class. Has nothing to do with VB.NET vs
C#.

http://msdn.microsoft.com/library/d...ef/html/frlrfsystemdrawingcolorclasstopic.asp

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
 
T

Tina

but in vb I can say imports System.Drawing.Color and then just say red. I
can't do that in C# because it will only allow
namespaces in the using clause. So there appears to be a difference.
T
Claes Bergefall said:
Nope, you can't say "Red", "Yellow" etc. VB.NET needs Color.Red,
Color.Yellow etc just like C#
The reason you often don't need to type the whole namespace is because
VB.NET by default imports a bunch of namespaces (check the project
settings), System.Drawing being one of them. If you remove that import
from your project settings you would need to use System.Drawing.Color.Red
etc

/claes

Nicholas Paldino said:
Actually, I think that it does. I believe that VB does not require
the enumeration type or type to be declared before using a member from an
enumeration or a static member, so you could use statements like "Red",
"Yellow", etc, etc.

In C#, you need to say "Colors.Red", "Colors.Yellow", etc, etc.

Hope this helps.


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

Peter Bromberg said:
System.Drawing is a Framework Class. Has nothing to do with VB.NET vs
C#.

http://msdn.microsoft.com/library/d...ef/html/frlrfsystemdrawingcolorclasstopic.asp

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




:

As I continue to convert a large vb.net project to C# is am now seeing
that
the namespaces are different. I never expected this.

For instance in vb I use System.Drawing.Color so I can say red yellow,
etc.

But in C# Color is not in Drawing! Where is it?

Are there any docs on differences in the namespaces?

Thanks,
T
 
A

Alvin Bruney

Can you, i would think that would only work if you had a with clause?

--

________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------

Tina said:
but in vb I can say imports System.Drawing.Color and then just say red. I
can't do that in C# because it will only allow
namespaces in the using clause. So there appears to be a difference.
T
Claes Bergefall said:
Nope, you can't say "Red", "Yellow" etc. VB.NET needs Color.Red,
Color.Yellow etc just like C#
The reason you often don't need to type the whole namespace is because
VB.NET by default imports a bunch of namespaces (check the project
settings), System.Drawing being one of them. If you remove that import
from your project settings you would need to use System.Drawing.Color.Red
etc

/claes

Nicholas Paldino said:
Actually, I think that it does. I believe that VB does not require
the enumeration type or type to be declared before using a member from
an enumeration or a static member, so you could use statements like
"Red", "Yellow", etc, etc.

In C#, you need to say "Colors.Red", "Colors.Yellow", etc, etc.

Hope this helps.


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

message System.Drawing is a Framework Class. Has nothing to do with VB.NET vs
C#.

http://msdn.microsoft.com/library/d...ef/html/frlrfsystemdrawingcolorclasstopic.asp

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




:

As I continue to convert a large vb.net project to C# is am now seeing
that
the namespaces are different. I never expected this.

For instance in vb I use System.Drawing.Color so I can say red
yellow, etc.

But in C# Color is not in Drawing! Where is it?

Are there any docs on differences in the namespaces?

Thanks,
T
 
C

Claes Bergefall

Ahh, yes, you're correct. Import allows you to import both namespaces and
elements (i.e. classes etc), while the corresponding C# construct (using)
only allows namespaces, so there is a difference between them. I've never
used Import to import classes myself so I didn't know it was possible. Guess
you learn something new everyday :)

/claes

Tina said:
but in vb I can say imports System.Drawing.Color and then just say red. I
can't do that in C# because it will only allow
namespaces in the using clause. So there appears to be a difference.
T
Claes Bergefall said:
Nope, you can't say "Red", "Yellow" etc. VB.NET needs Color.Red,
Color.Yellow etc just like C#
The reason you often don't need to type the whole namespace is because
VB.NET by default imports a bunch of namespaces (check the project
settings), System.Drawing being one of them. If you remove that import
from your project settings you would need to use System.Drawing.Color.Red
etc

/claes

Nicholas Paldino said:
Actually, I think that it does. I believe that VB does not require
the enumeration type or type to be declared before using a member from
an enumeration or a static member, so you could use statements like
"Red", "Yellow", etc, etc.

In C#, you need to say "Colors.Red", "Colors.Yellow", etc, etc.

Hope this helps.


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

message System.Drawing is a Framework Class. Has nothing to do with VB.NET vs
C#.

http://msdn.microsoft.com/library/d...ef/html/frlrfsystemdrawingcolorclasstopic.asp

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




:

As I continue to convert a large vb.net project to C# is am now seeing
that
the namespaces are different. I never expected this.

For instance in vb I use System.Drawing.Color so I can say red
yellow, etc.

But in C# Color is not in Drawing! Where is it?

Are there any docs on differences in the namespaces?

Thanks,
T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top