Why "\n" is true doesn't compare? [closed] - c#

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
Look at the sceene here , please:
http://social.microsoft.com/Forums/getfile/3600/
why it's not matching?

EDIT: Okay, now we know it's XmlReader.Value, which does return a string, that's definitely not the problem. I'll leave the previous answer below for future reference.
My guess is that there are some "odd" Unicode characters which don't show up in the debugger... or that the watch window is behaving strangely. Putting a watch on xml.Value.ToCharArray() would help to show that.
(As an aside, giving a Dictionary<,> parameter the name list is very confusing...)
EDIT: Additionally, using bracing and indentation would also make your code easier to follow...
We can't tell for sure at the moment, but my guess is that the Value property is of type object, not string. That means that == and != perform reference comparisons (operators are overloaded, not overridden, remember). You want the polymorphic behaviour of:
if (xml.Value.Equals("\n"))
or if xml.Value can legitimately be null:
if ("\n".Equals(xml.Value))

Related

How to define CheckBox in C# [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I have a check box in my form that I need to define along with other fields for inserting data. But I am not sure How to define it for inserting data. Below is my code.
cmd.Parameters.AddWithValue("#EmailTmp", (txtEmail.Text));
cmd.Parameters.AddWithValue("#PhoneTmp", (txtPhone.Text));
cmd.Parameters.AddWithValue("#AgreeTmp", (cbAgree.CheckBox));
Looking at your pasted code, I think you want this:
cmd.Parameters.AddWithValue("#AgreeTmp", (cbAgree.Checked));
or possibly something like:
cmd.Parameters.AddWithValue("#AgreeTmp", (cbAgree.Checked ? 1 : 0));
cmd.Parameters.AddWithValue("#AgreeTmp", (cbAgree.Checked));
This will give you a boolean value of true if checked, false if not. SQL will translate this into a 0/1 if you have the field in the SQL db as a bit.
Edit: As a side note, you don't need the "#" in front of the AgreeTmp

Regular expression to avoid null values [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I dont know how to use regex ,i have seen them to be used in email validation ,Is there any way i could restrict null values by using regular expression
/^(.+)$/
This regex will match anything which isn't empty (require one or more character), but is it really usefull to check it with a regex ?
The answer is no. null is not a value. It indicates you that the pointer doesn't point to anything. You can use "assert", or just if(yourobject==null){}

About Custom validator for name field [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am Soft. Trainee.
I want to write a custom validator for Name field.
It should only include characters and space.
Please specify the code so that I can understand it well.
Kindly help.
Your question isn't very well defined so excuse me if I've taken it wrongly, but I'll have a go.
I would suggest a Regular expression validator (and maybe also add a Required Field Validator if the field is also required).
<asp:RegularExpressionValidator runat="server"
Text="Name isn't Valid"
ControlToValidate="nameTextBox"
ValidationExpression="^[0-9a-zA-Z ]+$"></asp:RegularExpressionValidator>
You may want to change the Expression to a more valid one for your situation, and obviously ensure the ControlToValidate points to the correct Textbox.

extract meaning of a word in C# [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I m doing a project which invoves extracting the semantics of a word. While doing some resaerch I found out it's better to get Synonyms of a word rather than trying to extract semantics.
What is the best way of doing this. I only need to get the synonym of a word.
Please help.
Find a thesaurus. Pay attention to its licensing. E.g., Roget's Thesaurus. There may be one that is better-suited to being parsed programmatically.
Parse the thesaurus. For example, you could might store it in a Dictionary<string,List<string>>.
Look up entries as needed. How this is done depends on what data structure you stored it in. It's pretty easy in a Dictionary.
If you have trouble with a specific step in this process, feel free to ask. Your question is a bit too open-ending for me to know exactly what part to focus on.

Could I ever go back to not using ReSharper? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 13 years ago.
I have being using ReSharper (for C#) at work for about 2 years now. I am really missing ReSharper when I don't have it - could I ever go back to not using ReSharper?
I don't miss it because I'm not using it.
Looks like I shouldn't start to use ReSharper because there is no way back?
I completely agree. Coding without ReSharper is just not the same.
You don't know what you have until you lose it. Yes, I will always need ReSharper.

Categories