473,320 Members | 2,162 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Another VB to C# Question

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
May 22 '06 #1
9 1370
System.Drawing is a Framework Class. Has nothing to do with VB.NET vs C#.

http://msdn.microsoft.com/library/de...classtopic.asp

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


"Tina" wrote:
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

May 22 '06 #2
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]
- mv*@spam.guard.caspershouse.com

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:64**********************************@microsof t.com...
System.Drawing is a Framework Class. Has nothing to do with VB.NET vs C#.

http://msdn.microsoft.com/library/de...classtopic.asp

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


"Tina" wrote:
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

May 22 '06 #3
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 [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:eU**************@TK2MSFTNGP03.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:64**********************************@microsof t.com...
System.Drawing is a Framework Class. Has nothing to do with VB.NET vs
C#.

http://msdn.microsoft.com/library/de...classtopic.asp

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


"Tina" wrote:
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



May 22 '06 #4
this might also help you convert
http://www.developerfusion.co.uk/uti...btocsharp.aspx

"Tina" <ti**********@nospammeexcite.com> wrote in message
news:uA**************@TK2MSFTNGP03.phx.gbl...
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 [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:eU**************@TK2MSFTNGP03.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in
message
news:64**********************************@microsof t.com...
System.Drawing is a Framework Class. Has nothing to do with VB.NET vs
C#.

http://msdn.microsoft.com/library/de...classtopic.asp

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


"Tina" wrote:

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



May 22 '06 #5
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" wrote:
this might also help you convert
http://www.developerfusion.co.uk/uti...btocsharp.aspx

"Tina" <ti**********@nospammeexcite.com> wrote in message
news:uA**************@TK2MSFTNGP03.phx.gbl...
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 [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:eU**************@TK2MSFTNGP03.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in
message
news:64**********************************@microsof t.com...
System.Drawing is a Framework Class. Has nothing to do with VB.NET vs
C#.

http://msdn.microsoft.com/library/de...classtopic.asp

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


"Tina" wrote:

> 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
>
>
>



May 22 '06 #6
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 [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:eU**************@TK2MSFTNGP03.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:64**********************************@microsof t.com...
System.Drawing is a Framework Class. Has nothing to do with VB.NET vs
C#.

http://msdn.microsoft.com/library/de...classtopic.asp

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


"Tina" wrote:
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


May 23 '06 #7
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" <lo*****@nospam.nospam> wrote in message
news:uk*************@TK2MSFTNGP04.phx.gbl...
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 [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:eU**************@TK2MSFTNGP03.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in
message news:64**********************************@microsof t.com...
System.Drawing is a Framework Class. Has nothing to do with VB.NET vs
C#.

http://msdn.microsoft.com/library/de...classtopic.asp

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


"Tina" wrote:

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



May 24 '06 #8
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" <ti**********@nospammeexcite.com> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
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" <lo*****@nospam.nospam> wrote in message
news:uk*************@TK2MSFTNGP04.phx.gbl...
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 [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:eU**************@TK2MSFTNGP03.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in
message news:64**********************************@microsof t.com...
System.Drawing is a Framework Class. Has nothing to do with VB.NET vs
C#.

http://msdn.microsoft.com/library/de...classtopic.asp

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


"Tina" wrote:

> 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
>
>
>



May 24 '06 #9
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" <ti**********@nospammeexcite.com> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
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" <lo*****@nospam.nospam> wrote in message
news:uk*************@TK2MSFTNGP04.phx.gbl...
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 [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:eU**************@TK2MSFTNGP03.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in
message news:64**********************************@microsof t.com...
System.Drawing is a Framework Class. Has nothing to do with VB.NET vs
C#.

http://msdn.microsoft.com/library/de...classtopic.asp

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


"Tina" wrote:

> 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
>
>
>



May 25 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: fig000 | last post by:
Hi, I'm relatively new to Javascript so please bear with me on what might sound like silly questions. This is what I want to do: I'm working in classic asp (I have to for this project). I...
6
by: anon | last post by:
Post Forwarding question...... For this control below, <asp:Button runat="server" PostTargetUrl="page2.aspx" /> The Attribute: PostTargetUrl="page2.aspx" Is this PostTargetUrl Attribute...
2
by: terence.parker | last post by:
I am often faced with the dilemma of whether to use a JOIN query across three tables in order to grab a bunch of results - or whether to create another table to represent what I want. The latter is...
0
by: Sebastian Hiller | last post by:
Hello, i'm new to .Net (i'm using VB as language and i'm working in the code-behind mode) and i can't solve the following problem: I have a WebForm and want to Add a UserControl...
3
by: Brad | last post by:
I have another hopefully simple question. I am so used to writing VB .Net windows apps that there are some things in ASP .Net that just does not easily cross over. I know how to pass variables to...
27
by: Javier Martinez | last post by:
Hi I have asp application in a machine with a virtual directory referring a shared directory in another machine When I try to load any aspx page of my portal I get the following error: ...
17
by: Eric_Dexter | last post by:
def simplecsdtoorc(filename): file = open(filename,"r") alllines = file.read_until("</CsInstruments>") pattern1 = re.compile("</") orcfilename = filename + "orc" for line in alllines: if not...
24
by: David Mathog | last post by:
On a Solaris 8 system if a user "joe" logs in, for instance via ssh, cuserid() returns "joe". That's the expected behavior and so far so good. However if that user then does: % su - sally ...
13
by: shookim | last post by:
I don't care how one suggests I do it, but I've been searching for days on how to implement this concept. I'm trying to use some kind of grid control (doesn't have to be a grid control, whatever...
4
by: MichaelK | last post by:
Hello. I have all data already collected on the current page? I want to open another window with the form, fill the fields and submit that form. So basically the question is how can I fill all...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.