TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Marcin Niczuk
NA
5
645
filling table by yield return
Apr 21 2020 9:36 AM
Dear, I started adventure with C# a month ago. Can You please help me with problem below?
How to insert the results obtained by Yield return and insert them into table correctly? As far as result I get the table filled by the same,last generated value (10+5=15). What I need is to have series of results generated step by step by "yield return" function.
public class Obliczenia
{
// double P1, P2, V, S, R, P1a, Sa, Va;
public IEnumerable<double> Wyniki
{
get
{
for (double Rf = 0; Rf <= 10; Rf += 1)
{
yield return Rf + 5; // finally here will be more complicated equation
}
}
}
string[] tablica1 = new string[100];
Obliczenia o = new Obliczenia();
foreach (double wynik in o.Wyniki)
{
for (int i = 0; i < 9; ++i)
{
tablica1[i] = wynik.ToString(); //I think, something wrong is here.
}
Reply
Answers (
1
)
Text and methodes
Unpivot multiple columns