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
meena moon
NA
39
8.8k
How can reduce the number of Statements for this code in c#
Apr 18 2017 9:23 AM
Hi, how can I optimize my code? Reduce the number of lines(
Statements)
private void button1_Click(object sender, EventArgs e)
{
string[] seq1 = { "A", "C", "G", "T", "A", "C", "A", "G","T","G" };
string[] seq2 = { "T", "A", "C", "A", "C", "G","A","A","G","T" };
string[] res1 = new string[seq1.Length];
string[] res2 = new string[seq1.Length];
for (int i = 0; i <= 4; i++)
{
res1[i] = seq1[i];
res2[i] = seq2[i];
textBox1.Text +=" "+ res1[i];
textBox2.Text +=" "+ res2[i];
}
for(int i = 5; i < seq1.Length; i++)
{
if (seq1[i] == "T" )
{
res1[i] = "A";
}
else
if (seq1[i] == "A" )
{
res1[i] = "T";
}
else
if (seq1[i] == "C" )
{
res1[i] = "G";
}
else
if (seq1[i] == "G" )
{
res1[i] = "C";
}
textBox1.Text += res1[i]+" ";
}
for (int i = 5; i < seq2.Length; i++)
{
if (seq2[i] == "T")
{
res2[i] = "A";
}
else
if (seq2[i] == "A")
{
res2[i] = "T";
}
else
if (seq2[i] == "C")
{
res2[i] = "G";
}
else
if (seq2[i] == "G")
{
res2[i] = "C";
}
textBox2.Text += res2[i] + " ";
}
}
Reply
Answers (
6
)
About project how to create web application
Create multiple IDs in one task process