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
Amit Padhiyar
1.3k
448
6.5k
How do i reduce loop size using list or linq in C#
Jul 25 2019 4:51 AM
First, I used 1000 time loop for drawing lines
int x = 0;
for(int i=0;i<999;i++){
Line l = new Line();
l.X1 = x;
l.X2 = x;
l.Y1 = 0;
l.Y2 = 50;
Somthing.Children().Add(l);
x+=15;
}
Then i got second idea..
Loop size will reduce by 1000/5 = 200
int x = 0;
for(int i=0;i<199;i++){
Line l1 = new Line();
l1.X1 = x;
l1.X2 = x;
l1.Y1 = 0;
l1.Y2 = 50;
Somthing.Children().Add(l1);
x+=15;
Line l2 = new Line();
l2.X1 = x;
l2.X2 = x;
l2.Y1 = 0;
l2.Y2 = 50;
Somthing.Children().Add(l2);
x+=15;
Line l3 = new Line();
l3.X1 = x;
l3.X2 = x;
l3.Y1 = 0;
l3.Y2 = 50;
Somthing.Children().Add(l3);
x+=15;
Line l4 = new Line();
l4.X1 = x;
l4.X2 = x;
l4.Y1 = 0;
l4.Y2 = 50;
Somthing.Children().Add(l4);
x+=15;
Line l5 = new Line();
l5.X1 = x;
l5.X2 = x;
l5.Y1 = 0;
l5.Y2 = 50;
Somthing.Children().Add(l5);
x+=15;
}
Now i need something that can reduce code + fast execution with small loop
Reply
Answers (
3
)
Can not display interface method result data in datagridview
Regex split function,