Click here to Skip to main content
16,004,836 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I want to display "" in a textbox by default.

What I have tried:

i tried this txtabc.Text = """"; it is showing error.

i checked in google and i don't find any solutions. please assist.

Thanks in advance
Posted
Updated 1-Apr-16 4:05am

To complement the (perfectly valid) solution 1, let me explain you what is going on.

Since the strings are delimited by double quotes, if you want a double quote in the string you have two ways to do that:

1- By escaping the double quotes you want to put in the string (like in solution 1); escape character is backslash (\).

2- By doubling each double-quote you want in the string, but then you have to use a string literal. Thus, adapted to your question:
C#
txtabc.Text = @"""""";

Hope this helps.
 
Share this answer
 
v2
Comments
Karthik_Mahalingam 1-Apr-16 10:15am    
Hi Phil
i am getting syntax error for txtabc.Text = """""";
Please check.
phil.o 1-Apr-16 10:24am    
You are right, I just checked. I remember this was possible a few years ago.
Now it seems you have to do it in a string literal; I modified my answer accordingly.
Thanks a lot for reporting.
Karthik_Mahalingam 1-Apr-16 10:28am    
:) welcome phil
Renjith_R 1-Apr-16 10:27am    
Hello Phil
Thanks for the reply..
txtabc.Text = "\"\""; is working for me.
Sergey Alexandrovich Kryukov 1-Apr-16 22:41pm    
5ed.
—SA
try this

C#
txtabc.Text = "\"\"";
 
Share this answer
 
Comments
Renjith_R 1-Apr-16 10:27am    
Thanks dude. it is working fine
Karthik_Mahalingam 1-Apr-16 10:31am    
welcome :)
Sergey Alexandrovich Kryukov 1-Apr-16 22:41pm    
5ed. (Incomplete, but what's the hell?)
—SA

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