Part 2 C# Syntax for VB.net
Part 2 C# Syntax for VB.net
1).Any Collection value has to be accessed using index for example ArrayList
MyArrayList[0].ToString();
All Index has to be accesses using Square brackets
2). Even Integer Variable Can't be used directly without assign values
Int16 intValue;
Int16 intloop;
for (intLoop = 0; intLoop <= 5;intLoop ++)
{
intValue += intLoop;
}
This will give compile time error. for intValue is not assigned before using.
Code has to be
----> Int16 intValue =0;
3.Intization of Value or Calls using constructor
using System.Collections;
ArrayList MyArrayList = new ArrayList();
DataEntry MyDEntry = new DataEntry();
4.All methods will end with () Open And Close Brackets
Example : intValue.ToString();
5.Defining Properties
string myStringValue;
public string AccountName
{
get
{
return myStringValue;
}
set
{
mystringValue= value;
}
}
WriteOnly Property
public string mystringValue
{
set
{
mystringValue= value;
}
}
6.Construtors in Class
To Create Consrutors in C#. Name of Class to be same as Consrutors
No void keyword will be used.
publiC class MyClass
{
string MyStrValue;
public MyClass(string Value)
{
MyStrValue = Value;
}
}
7.Reading Value form DataGridView
Code :- lngRecordID = Convert.ToInt64(dataGridView1.Rows[e.RowIndex].Cells[0].Value);
8.Try Catch
try
{
catch (Exception EX)
{
MessageBox.Show("Error Occured :-" + EX.Message ,"Error in Save", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
9.Reading Value from DataTable
Code :- DtAccount.Rows[0]["AccountName"].ToString();
10.Row Based Value Access in C# has to be done using [] Square brackets
11. Reading Numeric value from textbox to Double Variable. C# will not allow to do this direct as we do it in VB.net
ex. double dblValue =0;
dblValue = textbox1.text; // Willl arise compile time error
dblValue = Convert.ToDouble(Textbox1.text.Tostring());
Comments
Post a Comment