Learning c# for VB.NET Developer

G

GaryB

I am experienced in .net development using VB. Is there any material
available geared to someone that knows .NET and VB.NET to learn C#?

thanks,
Gary
 
L

Lloyd Dupont

I think a book kind of "Teach yourself C# in 21 days" will do ;)
Otherwise in the SDK'c doc, there are C# specification, tutorial,
documentation:
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/csref/html/vcoriCSharpTutorials.htm
 
L

Lloyd Dupont

alternatively, if the links doesn't work, open .NET SDK help, and in the
search text box type:
"C# tutorial"

there is an entry called like that!
 
M

MikeY

I rather like the Wrox books. The have something for everyone, at every
level and with pretty good tutorial/examples.

MikeY
 
K

Kevin Aubuchon

It's not hard to convert VB.NET to C#. Most of .NET coding is using the
Framework, which is the same for both languages. Just read some basics about
C# syntax. Take some easy VB code, try and modify it to C# and see if it
compiles. Here is a little class I just rewrote in VB that show several
language features.

public class WorkerBee
{
public delegate void UpdateGui(string[] ar);
public event UpdateGui guiFunc = null;

private Thread thd = null;

public volatile bool bStopNow = false;

public WorkerBee(UpdateGui gptr)
{
guiFunc = gptr;
thd = new Thread (new ThreadStart (work));

}
public void Run()
{
thd.Start ();
}
private void work()
{
Debug.WriteLine (string.Format ("work() thd =
{0}",Thread.CurrentThread.GetHashCode()));
int k =0;
string [] sa = new string[10];
for (k = 0; k < 10000; k++)
{


if ((k % 10) == 0 && k > 0)
{
if (bStopNow) break;
if (guiFunc != null)
{
guiFunc(sa);
}
}
sa[k % 10] = string.Format ("string:{0}",k);
}
guiFunc(sa);
sa[0] = "101";
guiFunc(sa);
}
}


Imports System.Threading
Public Class WorkerBee

Public Delegate Sub UpdateGui(ByVal ar() As String)
Public Event guiFunc As UpdateGui

Private thd As Thread

Dim bStopNow As Boolean = False

Public Sub WorkerBee(ByVal gptr As UpdateGui)

AddHandler guiFunc, gptr
thd = New Thread(New ThreadStart(AddressOf work))

End Sub
Public Sub Run()

thd.Start()
End Sub
Private Sub work()

Debug.WriteLine(String.Format("work() thd = {0}",
Thread.CurrentThread.GetHashCode()))
Dim k As Int32 = 0
Dim sa(10) As String
For k = 0 To 100000
if ((k % 10) == 0 && k > 0) then

If (bStopNow) Then Exit For

RaiseEvent guiFunc(sa)
End If
sa(k Mod 10) = String.Format("string:{0}", k)
RaiseEvent guiFunc(sa)
sa(0) = "101"
RaiseEvent guiFunc(sa)
Next
End Sub
End Class


good luck,
kevin aubuchon
 
G

Guest

Learn the following:
1) what "using" blocks do and how to use them
2) The curly-bracket style syntax, and the implications this has on
visibility (i.e. you can see "out" of a block, but you can't see "into" one
3) The fact that you have to put a colon ";" at the end of each line that
you don't want to continue, and if you want to continue a line you just
*don't* put ";" at the end, rather than putting "_" at the end
4) The conditional expression syntax - i.e. "cond ? trueexpression :
falseexpression"

Once you've grasped the above, then you can safely claim you have as much
experience in C# as you do in VB.NET, as the rest is pure framework.
 
J

Jon Skeet [C# MVP]

Bonj said:
Learn the following:
1) what "using" blocks do and how to use them
2) The curly-bracket style syntax, and the implications this has on
visibility (i.e. you can see "out" of a block, but you can't see "into" one
3) The fact that you have to put a colon ";" at the end of each line that
you don't want to continue, and if you want to continue a line you just
*don't* put ";" at the end, rather than putting "_" at the end
4) The conditional expression syntax - i.e. "cond ? trueexpression :
falseexpression"

Once you've grasped the above, then you can safely claim you have as much
experience in C# as you do in VB.NET, as the rest is pure framework.

I don't think that's true at all. Here are other things:

1) Operator differences (&&, || etc)
2) Loop construct differences (the anatomy of for, foreach etc)
3) The syntax for declarations (of classes, variables, interfaces etc)
4) Unsafe code
5) Operator overloading
6) XML documentation
7) Event declaration and handling

I could go on. Basically, there's an awful lot more to the differences
between VB.NET and C# than the parts you listed. While it's true that
learning the framework is much more important, and that C# as a
language can be learned quite quickly, it takes considerably more than
the points you quoted.
 
G

GaryB

I don't have any files ending in Totorials.htm on my computer. I am running
VS.NET and have the sdk but I can't find it.
Gary
 
R

Ravichandran J.V.

The following could help you learn C# faster

The words in [] are only for description

End of statement - ;
Method syntax
-------------
sub = void

Method signature - <scope> <return type> <method name> <(parameter
list)>[Method Body -]
{
[Returns] <return> value;
}

// End of Method Syntax - This is a single-line comment
/* This is a multi-line comment */
Example
-------
VB.Net
Public Sub Method1()

End Sub

C#

public void Method1()
{

}

VB.Net
Public Function Method1() As String
Method1="String"
End Sub

C#

public string Method1()
{

return "String";
}

Class Syntax
------------
<scope> [Keyword-]<class> <identifier>
[Class Body - ]
{

}

Example
VB.Net
Public Class MyClass

End Class

C#
public class MyClass
{

}

variable/object declaration - <Scope> <Type> identifier.
variable/object instantiation - <Scope> <Type> identifier=<new> <Type>

Example
VB.Net
Public i as Integer
C#
public int i;

VB.Net
Public ob As New MyClass()
C#
public MyClass ob;
ob=new MyClass();

Remember C# is case-sensitive.

with regards,


J.V.Ravichandran
- http://www.geocities.com/
jvravichandran
- http://www.411asp.net/func/search?
qry=Ravichandran+J.V.&cob=aspnetpro
- http://www.southasianoutlook.com
- http://www.MSDNAA.Net
- http://www.csharphelp.com
- http://www.poetry.com/Publications/
display.asp?ID=P3966388&BN=999&PN=2
- Or, just search on "J.V.Ravichandran"
at http://www.Google.com
 

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