Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
| Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 19th, 2005, 11:54 AM
sal sal is offline
Friend of Wrox
 
Join Date: Oct 2003
Location: Clarksville, TN, USA.
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts
Default Return ASCII values for a given string

Wuw can i do a loop on a string to return the ASCII values of the string

"This is a Test"

as the ASCII values? 84, 104, 104, etc.

I am trying to move the following SQL Server function to c#.
-------------------------------------------
SET TEXTSIZE 0

DECLARE @position int, @string char(8)

SET @position = 1
SET @string = 'This is a Test'
WHILE @position <= DATALENGTH(@string)
   BEGIN
   SELECT ASCII(SUBSTRING(@string, @position, 1))
         SET @position = @position + 1
   END
GO



I can do it in VB6, but I am not sure how to do this in C#. I have researched a ton and I am still at a loss.

Thanks,




Sal
__________________
Sal
 
Old May 19th, 2005, 03:59 PM
Friend of Wrox
 
Join Date: Jul 2004
Location: Tehran, , Iran.
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

Code:
            string s="abc";
            byte[] result=System.Text.Encoding.ASCII.GetBytes(s);
            foreach(byte b in result)
                textBox1.Text+=b.ToString();


_____________
Mehdi.
software student.




Similar Threads
Thread Thread Starter Forum Replies Last Post
Using DoCmd.RunSQL to return values jscully Access VBA 10 August 21st, 2017 12:58 PM
Converting a set of string to its ascii value... rittwick Beginning VB 6 4 April 2nd, 2007 10:46 AM
how to return string value with quotes (single or tllcll BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 3 November 10th, 2005 01:57 PM
Multiple Return Values Colonel Angus SQL Server 2000 2 June 2nd, 2004 09:11 AM
Return String is Different kochoo Classic ASP Components 2 October 19th, 2003 05:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.