User Profile

Collapse

Profile Sidebar

Collapse
guimel
guimel
Last Activity: Nov 30 '09, 01:45 PM
Joined: Oct 9 '09
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • guimel
    replied to read number and string cell format in c#?
    1. How are you reading your excel sheet ?
    2. You can't put null into a value type (int, double, etc.)
    3. To check if you can convert text into an int:
    Code:
    try{
      int value = int.Parse(text);
    }catch(FormatException){
      //handle failure to convert
    }catch(OverflowException){
     //handle failure to convert
    }
    or
    Code:
      int value;
      bool success = int.TryParse(text,
    ...
    See more | Go to post

    Leave a comment:


  • Is this true ? (that you can't access the controls once ShowDialog has returned). I often have the following:
    Code:
    void Configure(){
    frmConfigure frmconf = new frmConfigure(Title, setting1, setting2);
    if (frmconf.ShowDialog() == DialogResult.OK){
      setting1 = frmconf.Setting1;
      setting2 = frmconf.Setting2;
    }
    where
    Code:
    partial class frmConfigure{
    public string Setting1
    ...
    See more | Go to post

    Leave a comment:


  • It looks like the KeyValue of the event is the Ascii value of the key (in uppercase), thus the following works:
    Code:
    if (e.Modifiers == Keys.Control && e.KeyValue >='A' && e.KeyValue <='Z')
        int test = e.KeyValue - 'A' + 1;
    Be aware that this relies on undefined behaviour as it's never specified what the KeyValue of a specific key is.

    Edit:
    To make it a bit safer, you...
    See more | Go to post

    Leave a comment:


  • guimel
    replied to string.split
    It may be similar but it's not the same. You can't substitute a single char for a char array (or a string). One has a size information attached to it, the other not.


    What's the point of a public undocumented overload ? You don't know what it may throw, what pre and post condition it assumes and if it'll be working in the next iteration of the framework....
    See more | Go to post

    Leave a comment:


  • guimel
    replied to string.split
    So would I, but the documentation doesn't say so.


    I doubt a function that expect an array would accept a scalar. The first one needs to know the size of the array somehow.


    The problem is that 'intuitive', if not documented, may not work tomorrow or under some special conditions. You don't know, because it's not documented.


    Do they ?


    That's implicit conversion...
    See more | Go to post

    Leave a comment:


  • guimel
    replied to string.split
    Indeed, I'm only passing a single char not a single string.

    Furthermore, even if a string is a collection of char, I don't believe it is the same as an array of char:
    Code:
    string str="Hello World";
    char[] strconv1 = str; //error CS0029: Cannot implicitly convert type 'string' to 'char[]'
    char[] strconv2 = (char[]) str; //error CS0030: Cannot convert type 'string' to 'char[]'
    ...
    See more | Go to post

    Leave a comment:


  • guimel
    started a topic string.split

    string.split

    According to MSDN, All of the String.Split overloads take an array of char or an array of string as first parameter. However,

    string str = "Hello World";
    string[] split = str.Split(' ');

    works as well. Is there some sort of scalar promotion to array in C# or is there an overload missing in the description of string.split ?

    Cheers,

    Guillaume
    See more | Go to post
No activity results to display
Show More
Working...