Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ASCII Value of a character
Message
De
14/09/2005 12:18:26
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01049249
Message ID:
01049508
Vues:
23
>I know. I got that after I posted. I'm pulling my foot outta my mouth
>right now.<


LOL! I frequently put my foot in my mouth ... it's just that I very rarely do it publicly. <g>

~~Bonnie


>
>BTW, this also works:
>
>
>int iValue = Convert.ToChar(sChar);
>
>
>
>
>>>No I didn't. I asked how to get the ASCII value of a character.<
>>
>>You missed Cetin's point, Kevin. Substring does *not* return a character (char), it returns a string.
>>
>>~~Bonnie
>>
>>
>>
>>>
>>>>Kevin,
>>>>You asked how to convert char (unicode) to byte. But substring returns a string.
>>>>System.Text.Encoding.ASCII.GetBytes(sString) would return a byte[].
>>>>As I see you need it to validate a time string. Then you might instead directly use DateTime class' Parse.
>>>>Cetin
>>>>
>>>>>Not sure why this doesn't work. ascVal contains the character
>>>>>from the substring.
>>>>>
>>>>>Here's my code:
>>>>>
>>>>>
>>>>>for(int iChar = 1; iChar < sTime.Length; iChar++)
>>>>>{
>>>>>  sChar = sTime.Substring(iChar - 1, 1);
>>>>>
>>>>>  byte ascVal = System.Convert.ToByte(sChar);
>>>>>
>>>>>  // Allowable values are 0-9,';','A','M','P'
>>>>>  if ((iValue >= 48 && iValue <= 57) ||
>>>>>    iValue == 58 ||
>>>>>    iValue == 59 ||
>>>>>    iValue == 77 ||
>>>>>    iValue == 80)
>>>>>  {
>>>>>  }
>>>>>  else
>>>>>    bValid = false;
>>>>>
>>>>>}
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>>I am extracting characters from a string.
>>>>>>>
>>>>>>>How can I determine the ASCII value of the characters?
>>>>>>>
>>>>>>>Thanks
>>>>>>
>>>>>>byte ascVal = System.Convert.ToByte(char);
>>>>>>
>>>>>>Cetin
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform