write values C#
-
Thursday, February 09, 2012 11:13 AM
hi i have a console application in C# and just want to ask that i have a method named
writeValues("TZA",4,7);
i want to write TZA on 4th index to till 7th index
Please advice
Taha Zubair Ahmed Software Emgineer.
All Replies
-
Thursday, February 09, 2012 12:22 PM
The post is shift here
http://forums.asp.net/p/1767701/4824329.aspx/1?Re+write+values
Taha Zubair Ahmed Software Emgineer.
-
Sunday, February 12, 2012 2:44 PM
Hi,
String format = "{0,10}";
it's a format string , to right align the content positive value should be given. for left aligh negative value
refer : http://www.csharp-examples.net/align-string-with-spaces/to get exact O/P refer below code
Display("TAHA", 5, 7);
static void Display(string message, int startIndex, int endIndex)
{
int count = message.Substring(0, (endIndex - startIndex)).Length - 1;
String format = "{0," + (startIndex + count) + "}";
Console.WriteLine(format, message.Substring(0, (endIndex - startIndex) + 1));
}static void Main(string[] args)
{
Display("hello karthick", 5, 5);
}
static void Display(string message, int startIndex, int endIndex)
{
int count = message.Substring(0, endIndex).Length;
String format = "{0," + (startIndex + count) + "}";
Console.WriteLine(format, message.Substring(0, endIndex));
}Regards
Keyur

