Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Fniendss.

Please explain me this code.

what do you mean by String.Empty;
and also this complete line

C#
private static readonly string _connString = String.Empty;


private static readonly string _connString = String.Empty;
   SqlConnection con = new SqlConnection(_connString);




Thanks, By the way am using this code for registration page. Please explain me.
Posted
Updated 17-Dec-12 23:11pm
v2
Comments
MDubey1987 18-Dec-12 5:01am    
String.Empty represents empty string. Its value is equal to "".
Jibesh 18-Dec-12 5:12am    
Please add a more relevant question. we can explain lot about one single line. variable is private
static, read only and variable type string each item can be explained again in deep so be precise in your question for a better answer.

String.Empty is same as "" [nothing in double quotes]
txtbox1.text = String.Empty
and
txtbox1.text = ""

both are same

private static readonly string _connString = String.Empty;

means 
a read-only 
static (Shared = no instance specific class specific) 
variable 
_ConnString 
has been set to empty string

Happy Coding!
:)
 
Share this answer
 
Comments
Software Engineer 892 18-Dec-12 6:16am    
Thanks a lot.....
Aarti Meswania 18-Dec-12 6:19am    
welcome! :)
Glad to help you! :)
adriancs 18-Dec-12 8:13am    
whats the different between
<pre>public static readonly string SomeStr = "abcd";</pre>
and
<pre>public const string SomeStr = "abcd";</pre>?
Aarti Meswania 18-Dec-12 8:18am    
constant => can be modified runtime...

static readonly => can be modified runtime...
the containing class is allowed to modify it only
it just represents empty value u r not assigning any value for that. thats it.
 
Share this answer
 
 
Share this answer
 
The first line is DECLARING/DEFINING a string called _ConnString and the following portion initiualises it to nothing or empty.

The second line then continues where the first line left off and.......

Now that we are sure the _ConnString variable is empty...

A connection object is defined and created and the connectionstring property of the connection object is set to EQUAL the _ConnString value

so the second line defines a connection object and sets its connectionstring to nothing or empty.
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900