How to Break and Combine long Statements into multiple lines in Code-behind in VB.Net and C#?

 Posted by vishalneeraj-24503 on 11/25/2013 | Category: ASP.NET Interview questions | Views: 4102 | Points: 40
Answer:

In VB.Net, for line break we use "&" sign and followed by Underscore(_) whereas in C#, we use "+" sign or "@" sign for line break.

For Ex:- In VB.Net in btn_view event we can write:-

Protected Sub btn_view_Click(sender As Object, e As EventArgs) Handles btn_view.Click

Dim sql_query As String = String.Empty
sql_query = "select employee_name,employee_code from " & _
" employee_master where employee_id = some_thing " & _
" and status = 'AA'"
End Sub


In C#,

protected void btn_view_Click(object sender,EventArgs e) 

{
string sql_query = string.Empty;
sql_query = "select employee_name,employee_code from " +
"employee_master where employee_id = something " +
" and status = 'AA'";

string sql_query1 = string.Empty;
sql_query1 = @"select employee_name,employee_code from
employee_master where employee_id = something
and status = 'AA'";
}


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response