Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Simple loop in C#
Message
From
09/10/2006 10:07:05
Keith Payne
Technical Marketing Solutions
Florida, United States
 
 
To
09/10/2006 09:42:49
Irv Adams
MSC Managed Care, Inc.
Florida, United States
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01160532
Message ID:
01160541
Views:
16
This message has been marked as a message which has helped to the initial question of the thread.
>I have a simple programming assignment I'm trying to help my daughter with, but I'm a helpless FoxPro addict and I'm not sure how to do this in C.
>
>She needs to write a loop to parse a string backwards, so 'Hello World' becomes 'dlroW olleH' and so on. Very simple, I could do it in my sleep in Fox, but I'm awake and I don't know much about C.
>
>Thanks,

In C or C#?

C#:
			string source = "Hello World";
			string result = String.Empty;
			char[] srcArray = source.ToCharArray();

			int i;

			if (srcArray.Length > 0) 
			{
				for (i=srcArray.Length-1;i>-1;i--)
				{
					result += srcArray[i];
				}
			}
Straight C is a little more code. You have to use the string library (and header).
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform