|
In addition to what lmoelleb posted, I think it would be more reliable to use two XmlTextReader , call their Read methods to move from node to node and after each call compare their Value (and NodeType ) properties.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
www.troschuetz.de
|
|
|
|
|
Notice that
<test><hello>world</hello></test>
is identical to
<test>
<hello>world</hello>
</test>
but it is NOT identical to
<test><hello>
world
</hello></test>
|
|
|
|
|
in this case the only solution i can think is load in dataset , as the first answer ... do you have other ideas?
|
|
|
|
|
One can use XmlTextReaders instead of the StreamReaders. Also possible but more memory consuming: Load both files into a XmlDocument and compare the strings returned by the InnerXml property.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
www.troschuetz.de
|
|
|
|
|
I will use second case.
<test>
<hello>world
Thanks,
Hitesh
|
|
|
|
|
Hi..
I want to learn network programming using C#.
So, from where to start i.e. Sockets, TCP, etc
|
|
|
|
|
Search for sockets in CodeProject articles , there are a lot
|
|
|
|
|
Hello all,
I'd like to open a console window that is usable with System.Console.ReadLine/WriteLine from a WinForm.
I'm trying to do it by clicking a button, but I'm having difficulty figuring it out.
How do I create / initialize the window?
Also, are there any issues with passing info back and forth between the console window and the form?
Currently, I can get a string to output to the Output window when I click the button, but I want a console. I can also use the process control to call a cmd.exe window, but can't get the IO there...
Thanks in advance.
|
|
|
|
|
You might be able to create a cmd.exe process and then use the RedirectStandardInput and RedirectStandardOutput to the streams of the Console class (something like GetStandardInputStream and GetStandardOutputStream from the Console class). You should be able to then write using Console.WriteLine etc and read using Console.ReadLine etc to read and write from cmd.exe.
Note I havn't had the time to look it up properly, but then again that's your job , still might be useful to me when I get the time.
You know you're a Land Rover owner when the best route from point A to point B is through the mud.
Ed
|
|
|
|
|
How to check validation numeric field in C# coz C# doesn't has built-in IsNumeric function
Angela
|
|
|
|
|
Three ways
1 - use a MaskedEditBox
2 - write your own handler so the edit box only takes numbers
3 - use Char.IsNumber to check all the characters in the string.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
ok, thanks
|
|
|
|
|
Use this
public bool IsNumeric(string s)<br />
{<br />
try<br />
{<br />
Int32.Parse(s);<br />
}<br />
catch<br />
{<br />
return false;<br />
}<br />
return true;<br />
}<br />
Nikhil
|
|
|
|
|
Thanks for your source code
just now i also found another way to validate the numeric field, I would like to share it with you :
public bool chkNumeric(string strText)
{
char[] chars = strText.ToCharArray();
for (int i = 0; i < chars.Length; i++)
{
if (chars[i] > 57 || chars[i] < 48)
{
return false;
}
}
return true;
}
angela
|
|
|
|
|
this code wil not handle -ve numbers and number exceeding int max limit
Regards
Shajeel
|
|
|
|
|
|
Be careful. The exception police will get you. As has been explained to me, relying on exceptions is bad practice. Use TryParse instead of Parse and it returns a boolean to let you know if it worked or not.
|
|
|
|
|
Well you could just do like this:
try
{
Convert.ToInt32(txtstring);
}
catch
{
MessageBox.Show("You must input a numeric value!");
return;
}
-- modified at 2:53 Thursday 8th June, 2006
|
|
|
|
|
And whats about this...
if(!char.IsNumber(e.KeyChar)
e.Handled=true;
write it in the text control's KeyPress event.
_____________________________
Success is not something to wait for, its something to work for.
|
|
|
|
|
A couple of notes about the other replies:
1. You don't want to be catching exceptions as part of the normal logic flow. This is a well-accepted standard in software development.
2. You don't want to do this in a KeyPress event since that won't handle pasting code from another source.
For a more robust equivalent to VB's IsNumeric method see: http://www.tangiblesoftwaresolutions.com/Articles/CSharp%20Equivalent%20to%20IsNumeric.htm[^]
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter
Instant C++: VB to C++ converter
Clear VB: Cleans up VB.NET code
|
|
|
|
|
David Anton wrote: 2. You don't want to do this in a KeyPress event since that won't handle pasting code from another source.
Hi David Anton
I didn't understand this point!
_____________________________
Success is not something to wait for, its something to work for.
|
|
|
|
|
Standard Windows copy/paste doesn't trigger KeyPress events.
User the TextChanged event to capture pasting of text also.
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter
Instant C++: VB to C++ converter
Clear VB: Cleans up VB.NET code
|
|
|
|
|
David Anton wrote: Standard Windows copy/paste doesn't trigger KeyPress events.
User the TextChanged event to capture pasting of text also.
of course! I checked it last day and found the same situation. It means that we can't rely on only keyPress event for validation, we have to check some other events too; like, as you mentioned, TextChanged etc.
Thanks.
_____________________________
Success is not something to wait for, its something to work for.
|
|
|
|
|
this code may help you to check whether the given value is numeric or not
using System.Text.RegularExpressions;
public static bool CheckNumeric(string strText)
{
return CheckRegExPattern(@"^[0-9]+$", strText.Trim());
}
-- modified at 7:05 Friday 9th June, 2006
|
|
|
|
|
Suamal wrote: CheckRegExPattern
What is this? I didn't find it.
Suamal wrote: using System.Text.RegularExpressions;
public static bool CheckNumeric(string strText)
{
return CheckRegExPattern(@"^[0-9]+$", strText.Trim());
}
While taking idea from this I tryed to implement it like this:
using System.Text.RegularExpressions;<br />
public bool CheckNumeric(string strtext)<br />
{<br />
System.Text.RegularExpressions.Regex rr = new Regex(@"^[0-9]+$");<br />
return rr.IsMatch(strtext); <br />
}<br />
<br />
MessageBox.Show(this.CheckNumeric(TextBox1.Text).ToString());
Its working, but i'm unable to interpret this @"^[0-9]+$"
Thanks and Best Regards
_____________________________
Success is not something to wait for, its something to work for.
|
|
|
|