Since some people have some confusion on VB.Net and C # selection, it is only a syntax habit, I put their grammar to compare, everyone has a sense of understanding.
1. Variable Name C # syntax INT X; String S; String S1, S2; Object O; Object Obj = new object (); public string name; VB Syntax DIM X AS INTEGER DIM S AS STRING DIM S1, S2 AS STRING DIM O 'Implicitly Object Dim Obj As New Object () Public Name As String 2 Statement C #: Response.write ("Chinese C # Technology Station"); VB: Response.write ("Chinese C # Technology Station") 3. Note Strategy // Chinese C # Technology Station / * Welcome Access, Chinese C # Technology Station * / VB: 'Chinese C # Technology Station 4. Get the variable passing the URL pass C #: String s = request.queryString ["name"]; string value = request.cookies [" Key "]; VB: DIM S, VALUE AS STRING S = Request.QueryString (" Name ") value = request.cookies (" key "). Value 5. Declaration property C #: public string name {get {... return ...;}}} VB: Public Property name as string get ... return ...; end get set ... = value; End set End Property 6. array c # string [ ] A = new string [3]; A [0] = "1"; a [1] = "2"; A [2] = "3"; // 2D array String [] [] a = new string [3] [3]; A [0] [0] = "1"; a [1] [0] = "2"; a [2] [0] = "3"; VB: DIM A (3) As string a (0) = "1" a (1) = "2" a (2) = "3" DIM A (3, 3) AS String A (0) = "1" A (1, 0 ) = "2" a (2, 0) = "3" DIM A () AS String a (0,0) = "1" a (1,0) = "2" a (2, 0) = "3" DIM A (,) AS String A (0, 0) = "1" A ( 1, 0) = "2" A (2, 0) = "3" 7 variable initialization C #: string s = "hello world"; int i = 1 double [] a = = = 3.00, 4.00, 5.00}; VB: DIM S as string = "Hello World" DIM I as button = 1 DIM A () as double = {3.00, 4.00, 5.00} 8; judgment statement (if statement) IF (Request.QueryString! = Null) {... } VB: if not (Request.QueryString =
NULL) ... END IF 9. Branch statement (CASE statement) C #: switch (firstname) {Case "john": ... Break; Case "Paul": ... Break; Case "ringo": ... Break;} VB: Select (firstname): ... case "paul": ... case "rinco": ... End select 10 for loop statement C # for (int i = 0; i <3 ; I ) a (i) = "test"; VB: DIM I as integer for i = 0 to 2 a (i) = "test" next 11 while loop C #: int i = 0; while (i <3) { Console.Writeline (I.Tostring ()); i = 1;} VB: DIM I as INTEGER I = 0 do while i <3 console.writeline (i.tostring ()) i = i 1 loop 12 string Connecting C #: String S1; String S2 = "Hello"; S2 = "World"; S1 = S2 "!!!"; VB: DIM S1, S2 AS STRING S2 = "Hello" S2 & = "World" S1 = S2 & "!!!" Declaration C #: void mybutton_click (object sender, evenetargs e) {...} VB: Sub mybutton_click (sender as object, e as evenetargs) ... End Sub 13 Declaration Object C # MyObject Obj = (MyObject) session ["some value"]; IMYOBJECT IOBJ = OBJ VB: DIM BJ As MyObject Dim Iobj As IMYObject Obj = session ("Some Value" IOBJ = CTYPE (Obj, IMYObject) 14 Data Type Conversion C # Int i = 3; s TRING S = I.TOString (); double d = double.parse (s); VB: DIM I AS DIM S AS STRING DIM D AS DOUBLE I = 3 s = i.toString () D = CDBL (s) 15 Class declaration and inheritance C #: use system; namespace myspace {public class foo: bar {int x; public foo () {x = 4;} public void add (int x) {this.x = x;} public int int GetNum () {returnx x;}}} VB: imports system namespace myspace public class foo: inherits bar Dim x as integer pub1 () mybase.new () x =