Getchar in sahil’s post

Posted: February 1, 2005 in Uncategorized

While going through the  blog of sahil i had gone through his post on getchars look the link

http://codebetter.com/blogs/sahil.malik/archive/2005/01/28/48887.aspx?Pending=true

Here is my commnets on the same:-

hi sahil,

i think you might have misguided.as per your logic the same would not be compiled with error but you have given the wrong inputs.Below is the code kindly look i have given test data only.

 

using (SqlConnection conn = new SqlConnection("constr here"))
   {
    SqlCommand cmd = conn.CreateCommand();
    cmd.CommandText = "Select * from emp";
    conn.Open();
    SqlDataReader dr = cmd.ExecuteReader();
    dr.Read();
    long i;
    char[] chr=new char[4];
    i=dr.GetChars(1,1,chr,1,1);
    //char c = dr.GetChar(1);
    MessageBox.Show(i.ToString());
   }

may be i am wrong.kindly put ur comments on same.

I was indeed wrong considering getchar as getchars();see the commnets….

thanks
shreeman

Advertisements
Comments
  1. Shreeman says:

    HiSahil is correct in saying that the getchar() is giving the exception.I tried to use the getchars it was a misunderstanding between getchar and getchars hoom…the ..s..is all about it.however the getchar is not supported in intellisense thus..here is the comment from sahil:-Shreeman .. The point was .. GetChar compiles, and the MSDN says it will return you one character. But it is in truth not implemented. Yes I could do GetChars .. but .. this blog post is about GetChar !! So no .. no misguiding here :-) _ SM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s