Lets go into slowly.
Lets suppose I am building a SQL Query by actually hardcoding the syntax in code and taking parameter values for database..
The Code looks something like below
What I want now is to show output like below which should be perfectly aligned in a single line as highlighted by Yellow Line
I tried storing the contents in left in string a and contents in right in string b.
Further I used string.format something like below but that didn't work out.
That actually removes the spaces
string alignedtext = string.Format("{0,-10} | {1,5}", a,b);
So what is the best way to manage spaces such that the output looks neat and clean.
Code is below
- if (attribute_unique_index_ind == "False")
- {
-
- strb_table_script.Append("\t,[" + attribute_name + "]" + " " + attribute_datatype + attribute_precision_value + " " + attribute_not_nullable);
- if (j + 1 < dv_entity_metadata.Count)
- strb_table_script.Append(Environment.NewLine);
- if (attribute_datatype == "VARCHAR")
- changemetxt = "'Change Me'";
- else if (attribute_datatype == "DATE")
- changemetxt = "'01/02/3456'";
- else
- changemetxt = "'Change Me'";
- string a = Environment.NewLine + "\t," + changemetxt + "AS" + " [" + attribute_name + "]";
- string b = "/*" + attribute_not_nullable + "|" + attribute_datatype + attribute_precision_value + "< --- UPDATE */";
- string alignedtext = string.Format("{0,-10} | {1,5}", a,b);
- strb_sp_custom_block_script.Append(alignedtext);
- }