|
I use a panel to simulate a scollbar put when i move it, just flicker.
How can i avoid this?
|
|
|
|
|
Use double buffering. There are several articles on this site and on the web relating how to do this.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Little House on the Flickr
Judah Himango
|
|
|
|
|
I am quite a novice at C# and have been making regular contributions to this board as a result. I was just wondering if there was a function to find a number in a string? Any help will be appreciated!
|
|
|
|
|
use the
\d+ regular expression.
<edit;Modified as per Leppie remark. Tx.</edit>
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
-- modified at 10:34 Wednesday 11th January, 2006
|
|
|
|
|
Thanks for the response. I however am not really familiar how Regex works. So how would I use that?
|
|
|
|
|
See the other answer. It is not complete, but MSDN has a topic explaining how to use the classes from the System.Text.RegularExpressions namespace.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
|
Tx, I corrected it. I am a little rusty on regex
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
There are lots of ways, depends on what you want to do with the number.
#1
mystring.IndexOf(string.Format("{0}", number)); will return -1 if the number is not found, a valid index otherwise
#2
MatchCollection matches = Regex.Matches(mystring, @"\d+", RegexOptions.Compiled) will search the string for all occurences of any digits
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
With regards to your second approach how does one access the matches. I have tried reading about them on the MSDN but cant see any way to access the contents. Any help would be appreciated!
Greeeg wrote: #2
MatchCollection matches = Regex.Matches(mystring, @"\d+", RegexOptions.Compiled) will search the string for all occurences of any digits
|
|
|
|
|
foreach (Match m in matches)
{
Console.WriteLine(m.Value);
}
This will loop through all matches found. It is saved as a string, you will need to convert to an integer by yourself using int.Parse(m.Value);
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
How to communicate between two worker threads in C#
Pls reply if u know the answer
|
|
|
|
|
Events (AutoResetEvent, ManualResetEvent) and shared variables (locked as needed)
|
|
|
|
|
Butthe problem in that is that the function would be executedon the behalf of worker thread,u getting me,I want after the worker thread ghas completed his job,it shouls inform another worker thread to do his job
|
|
|
|
|
I understand what you want, but I do not see what additional information you need.
Create a variable (or queue to handle multiple request serially) protected by locks (or using a syncronized queue).
Thread 1 does whatever it needs, then insert the "task" in the variable or queue. Once it is inserted it sets the event.
Thread 2 simply waits for the event to be raized. Once raized it takes the work object and do whatever it needs to do. For a queue, keep looping until all data is done, then wait for the event. For the variable you might need an extra event from thread 2 to inform thread 1 that it can override the variable - all in all the queue is simpler.
Obviously you have to be careful with timing.
|
|
|
|
|
Well,probably i did not make myself clear
Ss I don't want my main thread to stop processing or wait for it,See what i want is the functionaliyu available in GUi threads (PInvoke) in a console based applications
That when the worker thread completes it informs other thread A ,and call a function of A on the behalf of A,not its own
|
|
|
|
|
Hi,
I am new to XML and C#. I want to load this XML via the below code to an XmlDocument but it returns an Error which I don't know how to handle it. Here is the XML:
<?xml version="1.0" encoding="UTF-8"?>
<epp xmlns="urn:iana:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:iana:xml:ns:epp-1.0 epp-1.0.xsd">
<response>
<result code="1000">
<msg lang="en-US">Command completed successfully</msg>
</result>
<resData>
<contact:creData>
<contact:id>Epp1464</contact:id>
</contact:creData>
</resData>
<trID>
<clTRID>CrtContact0031</clTRID>
<svTRID>CrtContact0031-OLNIC-SRV</svTRID>
</trID>
<chksum>979170f7c148e945e352c7d155da8ac2</chksum>
</response>
</epp>
And here is my code. Actually I need also to know how to get the <contact:id> and <result> node bvalue and attribue.
try
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(strXMLSrc);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
Please help.
Samy
-- modified at 8:35 Wednesday 11th January, 2006
|
|
|
|
|
Please always include the error - saves the rest of us from running it so see the problem.
You are missing a namespace decleration for "contact".
If you do not know how XML namespaces work, you can for example look here:
http://www.w3schools.com/xml/xml_namespaces.asp[^]
|
|
|
|
|
Hi,
I am so sorry. Here si the error.
'contact' is an undeclared namespace. Line 8, position 2.
As It shows the namespace is not defined.
But the XML is generated by a server and I can't change the strcuture. Therefore How can I bypass this error checking.
Regards,
Samy
|
|
|
|
|
What's the error message?
|
|
|
|
|
Hi,
I am so sorry. Here si the error.
'contact' is an undeclared namespace. Line 8, position 2.
As It shows the namespace is not defined.
But the XML is generated by a server and I can't change the strcuture. Therefore How can I bypass this error checking.
Regards,
Samy
|
|
|
|
|
Hi,
What is the difference between .parse and casting?
Is it true that in every case that you use .parse you can use casting instead?
Thanks
|
|
|
|
|
Parse will try to convert a value into another one, whereas casting will convert the bits in a way the compiler thinks it should be correct.
Casting a long to an int might cause loss of data. If you're lucky the compiler will give you a warning at compile time.
The Parse method will throw an exception at runtime if the parsing fails. You should use Parse when converting data entered by a user, e.g. to check if the text entered into a textbox is a double value.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
And, don't forget the TryParse variants that don't throw exceptions.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Parsing takes a string and tries to interpret it as a value, for an example a number or a date.
Casting will either tell the compiler to handle an object as a specific type, or transform a data type to a similar data type.
For an example, you can cast a string into the type Object (as String inherits from Object), then cast it back to the type String.
You can safely cast to a type with higher precision, like from an int to a long. You can also cast to a lower presicion type, like from a long to an int, but that will cause an exception if the value is to large.
You can't use casting instead of parsing. For an example you can't cast a string to an int.
---
b { font-weight: normal; }
-- modified at 17:18 Wednesday 11th January, 2006
|
|
|
|