C# String Split Returns Double Quotes Out Of No Where?
Dec 16, 2010
Why does this
string test = "Text1, Text2";
string [] tests = test.Split(", ".ToArray());
returns this
[0] = "Text1"
[1] = ""
[2] = "Text2"
what's with the quotes in tests[1] ? I thought the output would be like this
[0] = "Text1"
[1] = "Text2"
View 4 Replies
Similar Messages:
Apr 14, 2010
im trying to import a CSV file, however a single quote has been used to enclose strings ie. 'aaaa','bbbbbb',ccccccc'
Im having problems because some strings contain commas or apostrophes ie... 'aaaa,aaa' , bbbbb'bbbb',
This is causing me trouble and i need to replace the enclosing character for all strings from a single quote to a double quote....
I dont have access to the source that the csv was generated from, I just have the CSV file..
View 1 Replies
Nov 3, 2010
how this string concatenation taking place? i am really confuse what is happening why that slash i there and how the double quotes are used
SessionStateItemCollection items = new SessionStateItemCollection();
items["LastName"] = "Wilson";
items["FirstName"] = "Dan";
foreach (string s in items.Keys)
Response.Write("items["" + s + ""] = " + items[s].ToString() + "<br />");
Response.Write("items["" + s + ""] = " + items[s].ToString() + "<br />");
View 3 Replies
Feb 9, 2011
im using asp.net and somehow my escape characters dont seem to work
string testing = "my name is "abc"";
this gives the output : my name is "abc"
ive read all the tutorials, everywhere it says that ive to put " to use double quotes inside a string but i have no idea why my system isnt accepting the escape character.
View 7 Replies
Aug 20, 2010
I have string. There are no items to show in this view of the "Personal Documents" then assign to string str variable string str ="There are no items to show in this view of the "Personal Documents" library" Now planning to replace "" and make it to actual string to str object. I tried below, but did not worked
str = str.Replace(@"",string.Empty);
I want str value should be string str ="There are no items to show in this view of the "Personal Documents" library" I need to find this string in another string. While searching into that string. I couldn't found because str contains "".
View 4 Replies
Jul 10, 2010
I am trying to insert dynamic data into a onclick property for a control the code looks like this
onclick="openRadWindow('<%#Eval("ID";) %>','<%#Eval("ParentObjectID") %>');"
I cant get it to fire and the trouble seems to be the double quotes, what is the correct method on escaping the quotes so that this fires.
View 4 Replies
Aug 4, 2010
I am using .Net Framework 3.5 on an ASP.net web project using jquery.ajax to make web service calls. My web service returns objects serialized as JSON by specifying the content type of my POST as "application/json". I would like just one of my many properties to return a non quoted javascript function name instead of a quoted string. Serialized as such:
{"dataInit": functionName, "id": "myID"}
instead of
{"dataInit": "functionName", "id":"myID"}
View 2 Replies
Nov 30, 2010
Since both are acceptable by HTML as well as languages like ASP.NET and PHP when using attributes or strings, why is it that some people use single quotes and double quotes interchangeably? It is my understanding that it is syntactically correct to use double quotes where possible, single when you need to embed a double quote for inline logic. Is there something I am missing? For examples: HTML
<a href='[URL]
PHP
<? echo 'Hello World!'; ?>
ASP.NET
<form id='myForm' runat='server'></form>
View 7 Replies
Oct 13, 2010
I'm trying to get my URLs to contain double quotes (") and other special characters such as <, > etc in my MVC2 application. Here's an example:
[URL]
The above would throw up a System.ArgumentException: Illegal characters in path.
View 4 Replies
Jan 19, 2011
i am writing the following connection string into web.config but it giving me error.what is the correct way to write it?
<add name="stargaze_stargazeConnectionString1" connectionString="Data Source=.SQLEXPRESS;AttachDbFilename="D:Work At DS19th Janmyastrolove.com_newApp_DatadbName.mdf";Integrated Security=True;User Instance=True"/>
View 4 Replies
Aug 23, 2010
I am using SQL Server 2008 Web Edition and it seems my SQL queries are automagically having the double quotes replaced with ' + CHAR(34) + '. I am trying to pin down why this is happening, I am using Delphi with ASP.NET and using the ADO.NET object for the SQL.
Has anyone come across this before?
View 2 Replies
Jun 23, 2010
I'm working in a Repeater over blog posts and I'm displaying a ShareThis JavaScript piece at the bottom. The Title and URL of the post are being sent to JS. In one test case, the title of a post has a single quote, e.g. Mark's test post Since I need to preserve that single quote when being sent to ShareThis, I need to wrap that JavaScript string in double quotes, however the string is being bound via a Literal and I cannot wrap the literal in double quotes: This is want I want but DOES NOT WORK:
SHARETHIS.addEntry({ title: "<asp:Literal ID="ltlTitle" runat="server" />", etc..
I can only wrap the literal with single quotes like so:
SHARETHIS.addEntry({ title: '<asp:Literal ID="ltlTitle" runat="server" />', etc..
But that will result in bad front-end code:
SHARETHIS.addEntry({ title: 'Mark's test post', etc..
How can I encode this correctly or somehow wrap the control in double quotes? I'm aware of HttpUtility.HtmlEncode and Server.HtmlEncode
View 2 Replies
Nov 26, 2010
How can I put " in this regular expression
Regex PhRegEx = new Regex(@"^[a-zA-Z0-9-+_,(): ]*$", RegexOptions.Compiled);
View 1 Replies
Mar 10, 2011
i have a problem with syntax in my query andi, i have this
sqlStmt =
"SELECT Chron.ID, Chron.EmpID, Chron.WDate, Chron.OrID, Emplo.FName, Emplo.LName, Emplo.ID AS Expr1, Emplo.NUser,
Emplo.Passw FROM Chron INNER JOIN Emplo ON Chron.EmpID = Emplo.ID WHERE (Emplo.ID ='" & s1 &
"'AND Chron.WDate ='" &
"'"& s2 &
"')"
my problem is with the sigle and the double quotes, i tried some different methods but nothing.
View 5 Replies
Jul 29, 2010
I want user to allow double quotes(") in text box. I am trying it throught regular expression. How to put double quote (")in below expression.
[code]....
How to not allow < > in text box using regular expression.
View 2 Replies
Jan 22, 2011
How to disallow use of double quotes " in a textbox
View 5 Replies
Mar 24, 2011
using sql server 2005.I need to query some nchar fields to see if any of them contain string with double quotes (char(34)).whats the syntax to do this? I was thinking something like this but I think the first query would get exactly the text Char(34) when I only want to get the double quotes:SELECT fieldA FROM myTable where fieldA LIKE '%char(34)%'ORSELECT fieldA FROM myTable where fieldA LIKE '%'+char(34)+'%'
View 3 Replies
Mar 17, 2010
In VS2008, it used to be that whenever I was typing an html attribute in an .aspx page when I hit '=' a pair of double quotes was automatically inserted and the cursor placed inside them. I guess I've changed a setting, but I don't know what to change to get that functionality back. I am using Resharper if it makes a difference.
View 1 Replies
May 7, 2015
In my database, there is a column "summary" with single quot in it.I am fetching this data inside Gridview. Data is shown inside Gridview as:
<summary>"
I want single quot to be shown inside Gridview as (')for that I tried to change the code as below:
<asp:GridView ID="GridView1" runat="server" Width="100%" BackColor="White" DataKeyNames="IssueId"
AutoGenerateColumns="False" AllowPaging="True" PageSize="8" CssClass="Grid" OnRowDataBound="GridView1_RowDataBound">
[code]....
View 1 Replies
Jun 8, 2010
I have an asp.net page with a WebMethod on it to pass JSON back to my javascript. Bellow is the web method:
[WebMethod]
public static string getData(Dictionary<string, string> d) {
string response = "{ "firstname": "John", "lastname": "Smith" }";
return response;
}
When this is returned to the client it is formatted as follows:
{ "d": "{ "firstname": "John", "lastname": "Smith" }" }
The problem is the double quotes wrapping everything under 'd'. Is there something I've missed in the web method or some other means of returning the data without the quotes? I don't really want to be stripping it out on the client everytime. Also I've seen other articles where this doesn't happen.
View 2 Replies
Feb 15, 2011
I want to split a string that taking both string and integer values like (Cmp_12). I want to use them in Separately.
View 4 Replies
Aug 12, 2010
System.Web.Script.Serialization.JavaScriptSerializer s = new System.Web.Script.Serialization.JavaScriptSerializer();
result = s.Deserialize<Hashtable>(data);
Error is thrown if data is "{a:""test" 123",b:"hello" }"
No error is thrown if data is "{a:"test 123",b:"hello" }"
How do I adjust the data string so that no error is thrown even when there are quotes?
View 1 Replies
Nov 12, 2010
I have some code that splits a session into strings by a -
My session looks something like this 123-456-789- and I split it like this
Dim MyString As String() = Session("MySession").Split("-"C)
And i've got a some code like this
Dim x as Integer
For x = 0 to MyString - 1
Response.write("Ref: " & MyString(x) & "<br>")
Next
This writes the code like this
Ref: 123
Ref: 456
Ref: 789
Ref:
So it's adding an extra Ref where it shouldn't be because there is no data after the last -
Is there a way to stop this adding in the extra one?
View 1 Replies
Jan 21, 2010
I would like to split the string to the string array.
but when the string hasn't has the splite sperator, i can't put the string into string array directly.
how to do?
if (Str.Contains(','))
{
str_array=Str.Split(',');
}
else
{
str_array=Str; <-- error occurs at this line.
}
View 3 Replies
Dec 24, 2010
I have two sub routines that I've created to pull in my Membership user roles and assign the value/name of that role to the value of a cookie.
My first subroutine looks like this
[Code]....
At this point, role ID is a 1-dimentional array which is not acceptable for a cookie's value (it must be a string), but in Debug mode, I can see that the array does contain the correct roleID value. In my 2nd subroutine I change the value from array to string for no other reason than that it gives me an opportunity to see that the value of CookieValue() before it is converted does have the correct roleID.
[Code]....
Even though it still shows that string as having the correct value, it returns the object "System.String[]"
View 1 Replies