Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
May I know if it's possible for me to do something like this?
string userInput = Console.ReadLine();
string strNewValue = "{ \"name\" : '" + userInput + "'}";
if yes, how can I do it?
I think you wanted this?
string strNewValue = "{ \"name\" : \"" + userInput + "\"}";
Yes, that will certainly work.
seems like you are trying to convert the user input into a json object. you don't need to hardcode the string as like json object. use JsonSerializer instead. Have a look at it http://msdn.microsoft.com/en-us/library/cc197957(v=vs.95).aspx
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I have the string
"{ "type" : "Stage_FF_Hot_Alerts__c"}"
I want to it be
{ "type" : "Stage_FF_Hot_Alerts__c"}
i.e. I want to remove quotes from start and end. How can I achieve this?
You could use Trim:
var a = "\"{ \"type\" : \"Stage_FF_Hot_Alerts__c\"}\"";
var b = a.Trim('"');
Console.WriteLine(a);
Console.WriteLine(b);
It will remove all leading and trailing quotation marks.
Try it online
You can also use:
var quotedString = "\"hello\"";
var unQuotedString = quotedString.TrimStart('"').TrimEnd('"');
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have HashSet> collection. I want to display content of this HashSet in richTextBox ? How to convert this HashSet to right type ?
Try :
richTextBox.Text = string.Join("", yourSet.ToArray());
try this instead:
foreach (SortedSet<string> set in youHashSet)
{
richTextBox.Text = string.Join("", set.ToArray());
}
Well a little bit of more information would have helped. It's hard to say without seeing your code. But these are your basic steps
after you build your Hashset
then for a for or foreach loop on it
and then ToString the object if it's not a Hashset
string helloWorld = string.empty;
foreach(<whateverobject> myobject in Hashset<whateverobject> myHashsetList)
{
helloWorld = helloWorld = myobject.ToString();
}
richTextBox.Text = helloWorld;
If you delimit it or whatever that's up to you
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a string like below
he/a0h/a0dv/a0jks
I would like to be string become as below.
hehdvjks
Need to remove the "/a0" from the string.
The String.Replace method is what you're looking for, just do a;
String myString = "he/a0h/a0dv/a0jks"
myString = myString.Replace("/a0", "")
It'll return a modified 'myString' with all occurrences of the old value ("/a0") replaced with a new value (blank in this case).
The MSDN reference for String.Replace can be found at:
http://msdn.microsoft.com/en-us/library/fk49wtc1%28v=vs.110%29.aspx
var result = "he/a0h/a0dv/a0jks".Replace("/a0", string.Empty);
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
This line occur new line in constant error..how can i fix this?
Locations += Environment.NewLine + " map.addOverlay(new GMarker(new GLatLng(" + Latitude + "," + Longitude + ")));";
You can not use "\" string directly in C# code, it produces "new line in constant" error. One of your variables is equal to "\", I can not directly say since the code section you have provided does not include the related initialization code.
instead of using "\", just escape the slash character using "\\".
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I am trying read one string from TextBox and use in my script.
Suppose this TextBox name is: txt3.
I want read this value and use in below lines:
string s = Regex.Replace(str,
#"\btxt3.Text\b",
txt4.Text,
RegexOptions.IgnoreCase);
How I can write this #"\btxt3.Text\b" ?
I want write that as :
string str==#"\btxt3.Text\b";
You want something like:
String.Format(#"\b{0}\b", txt3.Text)
Try this
string s = Regex.Replace(str, string.Format(#"\b{0}\b",txt3.Text), txt4.Text, RegexOptions.IgnoreCase);
If you want to combine value of txt3 with other strings, one way to do it is write
"\\b" + txt3.Text + "\\b"
instead of
#"\btxt3.Text\b"