String iterations ....
-
question... why no loops? whats the point of not using the "tools" a language offers?
Harvey Saayman - South Africa Junior Developer .Net, C#, SQL think BIG and kick ASS
you.suck = (you.passion != Programming)
-
Thanq ... This is the Question i faced in an interview . Thats y am asking , is there any procedure to do it . thats all .... Thanq frnds ...
what was your reply to the question?
Harvey Saayman - South Africa Junior Developer .Net, C#, SQL think BIG and kick ASS
you.suck = (you.passion != Programming)
-
Hi Every 1, Iam new to C# (Object Oriented Concepts ) i have a doubt lie this ------------ I want to Repeat a String ( Satish ) for 100 times with out using any loops , arrays n conditions .. Ex : Satish Satish Satish Satish Satish Satish Satish - - - - Satish Like this 100 times i need ... Plz help me ... Thanks in Advance ...
Does following work?
public static void printit(string value, int num) { if (num < 1) return; num--; Console.WriteLine(value); printit(value, num); } static void Main() { printit("Satish", 100); }
Maruf Maniruzzaman Dhaka, Bangladesh. Homepage: http://www.kuashaonline.com
Blog you should not miss Tomorrow is a blank page -
Does following work?
public static void printit(string value, int num) { if (num < 1) return; num--; Console.WriteLine(value); printit(value, num); } static void Main() { printit("Satish", 100); }
Maruf Maniruzzaman Dhaka, Bangladesh. Homepage: http://www.kuashaonline.com
Blog you should not miss Tomorrow is a blank pageFunctional style :-) Well there is a condition in it so Id say it doesnt live up to the OPs requirements.
Blog: http://www.rogeralsing.com Projects: http://www.puzzleframework.com
-
what was your reply to the question?
Harvey Saayman - South Africa Junior Developer .Net, C#, SQL think BIG and kick ASS
you.suck = (you.passion != Programming)
-
Hi Every 1, Iam new to C# (Object Oriented Concepts ) i have a doubt lie this ------------ I want to Repeat a String ( Satish ) for 100 times with out using any loops , arrays n conditions .. Ex : Satish Satish Satish Satish Satish Satish Satish - - - - Satish Like this 100 times i need ... Plz help me ... Thanks in Advance ...
C#3
string res = Enumerable
.Repeat("Satish", 100)
.Aggregate((left, right) => left + Environment.NewLine + right);Console.WriteLine(res);
Do I get a cookie?
Blog: http://www.rogeralsing.com Projects: http://www.puzzleframework.com
-
C#3
string res = Enumerable
.Repeat("Satish", 100)
.Aggregate((left, right) => left + Environment.NewLine + right);Console.WriteLine(res);
Do I get a cookie?
Blog: http://www.rogeralsing.com Projects: http://www.puzzleframework.com
Enumerable maintains an array- am I right? ;P
Maruf Maniruzzaman Dhaka, Bangladesh. Homepage: http://www.kuashaonline.com
Blog you should not miss Tomorrow is a blank page -
Hi Every 1, Iam new to C# (Object Oriented Concepts ) i have a doubt lie this ------------ I want to Repeat a String ( Satish ) for 100 times with out using any loops , arrays n conditions .. Ex : Satish Satish Satish Satish Satish Satish Satish - - - - Satish Like this 100 times i need ... Plz help me ... Thanks in Advance ...
nareshss wrote:
i have a doubt lie this
You mean a question? ;) 1.
Console.Write(new String('x',100).Replace("x","Satish\r\n"));
Console.Write("ssssssssss".Replace("s","ssssssssss").Replace("s","Satish\r\n"));
public string msg(int cnt) { return "Satish\r\n" + (cnt > 1 ? msg(cnt - 1) : string.Empty); }
Console.Write(msg(100));Despite everything, the person most likely to be fooling you next is yourself.
modified on Monday, February 25, 2008 8:15 AM
-
nareshss wrote:
i have a doubt lie this
You mean a question? ;) 1.
Console.Write(new String('x',100).Replace("x","Satish\r\n"));
Console.Write("ssssssssss".Replace("s","ssssssssss").Replace("s","Satish\r\n"));
public string msg(int cnt) { return "Satish\r\n" + (cnt > 1 ? msg(cnt - 1) : string.Empty); }
Console.Write(msg(100));Despite everything, the person most likely to be fooling you next is yourself.
modified on Monday, February 25, 2008 8:15 AM
Guffa wrote:
Console.Write("ssssssssss".Replace("s","ssssssssss").Replace("s","Satish\r\n"));
Sheer genius. :laugh:
Knowledge is hereditary, it will find its way up or down. - Luc Pattyn
so you answer don't be scared of failure The only failure is never to try Things You've Never Done - Passenger -2008 -
nareshss wrote:
i have a doubt lie this
You mean a question? ;) 1.
Console.Write(new String('x',100).Replace("x","Satish\r\n"));
Console.Write("ssssssssss".Replace("s","ssssssssss").Replace("s","Satish\r\n"));
public string msg(int cnt) { return "Satish\r\n" + (cnt > 1 ? msg(cnt - 1) : string.Empty); }
Console.Write(msg(100));Despite everything, the person most likely to be fooling you next is yourself.
modified on Monday, February 25, 2008 8:15 AM
-
By using "Console.WriteLine" is the answer for my question . He asked me the basic question but i thought that there is any other tech to implement like that .... Thats wat ... ok Thanq Saayman ....
what about a recursive function?