473,851 Members | 2,164 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1392
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.co m

"Peter Bromberg [C# MVP]" <pb*******@yaho o.nospammin.com > wrote in message
news:64******** *************** ***********@mic rosoft.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.c om> wrote in
message news:eU******** ******@TK2MSFTN GP03.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.co m

"Peter Bromberg [C# MVP]" <pb*******@yaho o.nospammin.com > wrote in message
news:64******** *************** ***********@mic rosoft.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**********@n ospammeexcite.c om> wrote in message
news:uA******** ******@TK2MSFTN GP03.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.c om> wrote
in
message news:eU******** ******@TK2MSFTN GP03.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.co m

"Peter Bromberg [C# MVP]" <pb*******@yaho o.nospammin.com > wrote in
message
news:64******** *************** ***********@mic rosoft.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**********@n ospammeexcite.c om> wrote in message
news:uA******** ******@TK2MSFTN GP03.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.c om> wrote
in
message news:eU******** ******@TK2MSFTN GP03.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.co m

"Peter Bromberg [C# MVP]" <pb*******@yaho o.nospammin.com > wrote in
message
news:64******** *************** ***********@mic rosoft.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.c om> wrote in
message news:eU******** ******@TK2MSFTN GP03.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.co m

"Peter Bromberg [C# MVP]" <pb*******@yaho o.nospammin.com > wrote in message
news:64******** *************** ***********@mic rosoft.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******** *****@TK2MSFTNG P04.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.c om> wrote
in message news:eU******** ******@TK2MSFTN GP03.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.co m

"Peter Bromberg [C# MVP]" <pb*******@yaho o.nospammin.com > wrote in
message news:64******** *************** ***********@mic rosoft.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**********@n ospammeexcite.c om> wrote in message
news:%2******** ********@TK2MSF TNGP05.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******** *****@TK2MSFTNG P04.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.c om> wrote
in message news:eU******** ******@TK2MSFTN GP03.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.co m

"Peter Bromberg [C# MVP]" <pb*******@yaho o.nospammin.com > wrote in
message news:64******** *************** ***********@mic rosoft.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**********@n ospammeexcite.c om> wrote in message
news:%2******** ********@TK2MSF TNGP05.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******** *****@TK2MSFTNG P04.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.c om> wrote
in message news:eU******** ******@TK2MSFTN GP03.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.co m

"Peter Bromberg [C# MVP]" <pb*******@yaho o.nospammin.com > wrote in
message news:64******** *************** ***********@mic rosoft.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
2308
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 need to: 1. Click a submit button on an asp page, calling another page that saves the contents of that form to a database and then displays
6
1848
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 going to be available in the <a> and Html Controls as well as opposed to just the <asp:Button> control?
2
2678
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 less normalised, but seems less computationally expensive to me(?). Basicially what I have is: Friend (uid1,uid2,fid) -> FriendshipCategories(fid,cid) -> Categories(cid,name) If I want to find out all the 'categories' (names) which a user...
0
1437
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 (classname:QuestionControl) as many times as there are rows in a DataTable (also named Questions) in a DataSet. But this UserControl is ,for reasons of structuring, not a member of the WebForm Object in which it should be displayed, it is member of another class...
3
1409
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 another form, but how would I do this from one page to another? I am not finding a simple solution. Thanks for the help
27
2569
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: Mensaje de error del analizador: We can't load the type 'JULIAN.Global'.
17
2733
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 pattern1 print >>orcfilename, line I am pretty sure my code isn't close to what I want. I need to be able
24
2999
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 cuserid will still return "joe". However "sally" uses "tcsh" where whoami shows "sally". If the user running as "sally" creates a file the ownership is for "sally". "ps -ef" also shows the user shell running as "sally". While "sally"
13
2467
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 works best) to display a dropdown menu of fields populated from table tblInvoiceData. This control also includes a textbox which the user can input a value. These two columns are side by side and not in a vertical layout. The user then clicks on...
4
4359
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 fields and submit the form on another window. Regards, Michael
0
9897
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9747
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11019
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10670
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10728
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10356
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7906
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5736
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4549
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.