In C#,Verbatim (@) is the powerful string as ever.
It will take care of escape sequences.
Ex:
If you are going to assign a path value to some string
without verbatim,we need to specify the escape sequences.
string path = "C:\\log\\log.txt"
If we use verbatim,no need to take care of escape sequences.
string path = @"C:\log\log.txt"
It will used to supress the Keyword itself.
Ex:
if you are decalre the class as property name,
C# won't allow this coz of keyword.If you use
the verbatim (@),it is possible to suppress a keyword
public string @class
{
get{};
set{};
}
Monday, May 22, 2006
Verbatim Symbol ( @ ) in C#
Thursday, May 18, 2006
Convert Hexadecimal to Decimal
public string HexaToDecmialConversion(string hexvalue)
{
string decmialValue = "";
for(int i=0; i<hexvalue.Length; i+=2)
{
string hex = hexvalue.Substring(i,2);
decmialValue += Int32.Parse
(hex,System.Globalization.NumberStyles.AllowHexSpecifier).ToString();
}
return decmialValue;
}
Wednesday, May 17, 2006
Read the Values from Excel File
Using Microsoft Excel Driver,we can read the values from Excel files.
DataSet ds = new DataSet();
string connstr = @"Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq=D:\My.xls;DefaultDir=D:\sankar;";
OdbcConnection conn = new OdbcConnection(connstr);
conn.Open();
OdbcDataAdapter da = new OdbcDataAdapter("select * from [sheet1$]",conn);
da.Fill(ds);
da.Dispose();
DataGrid1.DataSource = ds;
DataGrid1.DataBind();
Subscribe to:
Posts (Atom)