Contact ~ Site Map ~ Navigation:   

 

Navigation
About Tutorials
Remove Background
Map Network Drive
Variable Naming
VB.NET Syntax
VB.NET to C#
Add Image

VB.NET to C#

Regardless of why, you're now faced with the task of converting something written in VB.NET into C# (or vice-versa), and you've used a few of those online conversion tools, but still you find that the code just doesn't work.

This is where I step in. Below are a few examples of code that I've found just doesn't convert using those .NET code converters. Hopefully these examples will help you to finally get that project completed.

VB.NET  
Dim sMonth As String = Now.Month.ToString
C#  
string sMonth = System.DateTime.Now.Month.ToString();
 
 
VB.NET  
Dim sMonthName As String = MonthName(Month(Now), False)
C#  
string sMonthName = DateTime.Now.ToString("MMMM");
 
 
VB.NET  
Public Const NEWLINE As String = vbCrLf
C#  
public const string NEWLINE = Environment.NewLine;
 
 
VB.NET  
Public Const TAB As String = vbTab
C#  
public const string TAB = "\t";
 
 
VB.NET  
Dim sValue As String = reader("FirstName")
C#  
string sValue = (string)reader["Name"];
 
 
VB.NET  
Dim sCampusName As String = Request.QueryString("Campus") & ""
C#  
string sCampusName = Request.QueryString["Campus"] + "";
 
 
VB.NET  
sPersonName = sPersonName.Trim
C#  
sPersonName = sPersonName.Trim();
 
 
VB.NET  
sName = dsValues.Tables(0).Rows(0).Item("Name") & ""
C#  
sName = dsValues.Tables[0].Rows[0]["Name"] + "";
 
 
VB.NET  
Dim arNames() As String = sAllNames.Split(",")
C#  
string[] arNames = sAllNames.Split(new string[] {","}, StringSplitOptions.None);
 
 
VB.NET  
Dim arBinaryData(9) As Byte
C#  
byte[] arBinaryData = new byte[9];
 
 
VB.NET  
For iLpr As Integer = 0 To UBound(arEmails) - 1
C#  
for (int iLpr = 0; iLpr <= arEmails.Length -1; iLpr++)
 
 
VB.NET  
Dim sFormName As String = [GetType].Name
C#  
string sFormName = GetType().Name;
 
 

 
© Copyright 1999 - 2017 Pharfruminsain.com, All Rights Reserved.