Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

yield c#

IEnumerable<char> hello()
{
	foreach (char ch in "hello world")
	{
		yield return ch;
	}
}
Console.WriteLine(hello());
//Submission#0+<hello>d__0                                                                                                                             
foreach(char ch in hello())
{
	Console.WriteLine(ch);
}
// h                                                                                                                                                    
// e                                                                                                                                                    
// l                                                                                                                                                    
// l                                                                                                                                                    
// o                                                                                                                                                    
//	
// w                                                                                                                                                    
// o                                                                                                                                                    
// r                                                                                                                                                    
// l                                                                                                                                                    
// d 
Source by w3programmers.org #
 
PREVIOUS NEXT
Tagged: #yield
ADD COMMENT
Topic
Name
7+7 =