|
That is what I want to do but the string is in a variable read in from a datareader and i am having trouble adding the quotes to a string which contains some text.
eg
string stext = "The text";
string stext1 = @"\"" + stext + @""\";
This does not work because the variable name is written as part of the text and not what is contained in the variable.
Any additional help is appreciated.
Thanks
|
|
|
|
|
That's because you have a mistake and stext is never even used!
This will work however:
string stext = "The text";<br />
string stext1 = "\"" + stext + "\"";
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Thanks Alex. That worked well.
Cheers
|
|
|
|
|
How do I get the current time? I couldn`t anything for it.
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|
|
DateTime.Now
More information here.[^]
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Well i`ve look into DateTime. How could I miss it?
|
|
|
|
|
I change the icon using the properties window. The problem is that only shows in the upper-left part of the application window.
It does not show when I create a shot-cut to the desktop.
What am I missing? (C#)
Your help is greatly appreciated
|
|
|
|
|
Go to the project properties page and change the icon there.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Hi all,
After searching some text book and reference, I am not still certain
on how to use lock(this) in C# for sychronized access of the statements
inside the locked range. e.g.
lock (this)
{
statement1;
statement2;
}
why we need to put the "this" (refer to the object) after the lock keyword,
what will be the effect when putting other stuff instead of the "this" ?
Thanks
Patrick
|
|
|
|
|
Hi,
Generally the lock keywork in csharp is used to give the locking to any function.Suppose you are having one routine and the same routine is calling by two different object so if you are doing this things without lock your code may be unsafe but if you will use lock keywork if one object calls this method and upto finished up the method (or routine) another object can't be able to excess the same routine unless and untill first one completes the one.
and regarding answer of this keyword,that is use for saying that we are using current object not any other one.that's it.
regards,
montu3377
|
|
|
|
|
As the MSDN states: "The lock statement obtains the mutual-exclusion lock for a given object, executes a statement, and then releases the lock."
So the lock(this) statement obtains a mutual-exclusion lock for the current object of your class. If you use this statement in two or more methods of your class, these methods cannot be executed simultaneously by one object of your class.
But they can be simultaneously executed by multiple objects of your class as each obtains a mutual-exclusion for itself. This is no problem if you want to synchronize access to instance members. To synchronize access to class members you should use the following statement: lock (typeof(yourClass)) .
Finally back to the initial question: You can use any object in combination with the lock statement, but make sure it's always the same, cause otherwise the mutual exclusion won't work.
www.troschuetz.de
|
|
|
|
|
As a good practice, never use lock (this) or lock (typeof(Class)). As an example, if you use lock (this), and then someone uses lock (yourObject), you can add subtle deadlocks in your program.
Always declare a new, private object on your classes to lock on and you'll be safe.
Yes, even I am blogging now!
|
|
|
|
|
hello the worlde
can you help me show port pc
and open or clos the port
|
|
|
|
|
More information please...
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Like Alex said, LOTS more information.
What kind of ports? Serial, Parallel, I/O ports, TCP/IP ports, UDP ports, ... We need alot more detailabout what your trying to do and/or what your having a problem with, otherwise, there is nothing we can do to help you.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
I need to translate a very large application to different languages and we will be using a custom tool to translate each form, reports, etc. We will not be using the localization features of .NET.
Is there an easy way for me to extract all the strings from the different assemblies and put them in an XML file for example?
Thanks!
Carl
|
|
|
|
|
If it was me, I'd write an app that uses regex to go over the cs files and make an xml file.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
i will use backpropagation, if i have a given number list of each number being 3 numbers ex. 123 should i make a network fully interconnected like this...
neuron1 neuron2 neuron3 <-input layer
neuron4 neuron5 neuron6 <-output layer
should i make a hidden layer and could someone help me please im confused, appreciate the help in advance
(this network will be using the next 3 digit number as training data)
IM PROUD TO BE A GMAIL;
|
|
|
|
|
Hello,
I tried many things but I allways failed to send more than one variable using POST method.
Here is a sample code I use:
<br />
HttpWebRequest hR = (HttpWebRequest)WebRequest.Create("http://www.foo.org/bar.php");<br />
hR.Timeout = 5000;<br />
hR.Method = "POST";<br />
string postData="username=admin";<br />
hR.ContentType="application/x-www-form-urlencoded";<br />
hR.ContentLength=postData.Length;<br />
StreamWriter newStream=new StreamWriter(hR.GetRequestStream());<br />
newStream.Write(postData);<br />
newStream.Close();<br />
Can somebody help me to mod it to send more than one POST variable.
Regards.
|
|
|
|
|
|
I've got a section of code in my app that keeps track of how much time an employee has accrued, which equals out to 1.33 days of PTO per month. I'm trying to store the time accrued so far in an XML file. I have no problems writing to and reading from the XML file and all my values are correct. The problem I'm having is my calculation never amounts to 1.33, it goes from
1.32999999999997
to
1.3743333333333.
on the next run.
My calculation is
int TimePerDay = 1.33 / DateTime.DaysInMonth(DateTime.Parse(DateTime.Now.ToShortDateString()).Year, DateTime.Parse(DateTime.Now.ToShortDateString()).Month);
I save the difference of that calculation in the XML file, and then retrieve it again when the calculation is necessary. Here is the code:
int TimeCount = System.Double.Parse(xmlDoc.ChildNodes.Item(1).ChildNodes.Item(1).InnerText);
//the first time I retrieve this value, it will be initially set to 0.0443333333333333 the first time this code runs
TimeCount += 1.33 / DateTime.DaysInMonth(DateTime.Parse(DateTime.Now.ToShortDateString()).Year, DateTime.Parse(DateTime.Now.ToShortDateString()).Month);
xmlDoc.Save(Path);
Like I said the problem is that calculation never amounts to 1.33 - I have ran it many times in a for loop without ever converting it to a string value. The for loop eventually calculates to 1.33, and it stops at 1.33 and displays that fact in a MessageBox. I think I may be having a problem with the System.Double.Parse parser . . . anybody got any idea's?
__________________________________________________
Go ahead, code by the seat of your pants. It gives me more billable hours in the long run ...
|
|
|
|
|
I believe that Decimal is more accurate.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
unfortunately I get the same result when working with the decimal type . . .
If you put a time limit on this project, it won't ever get finished . . .
|
|
|
|
|
THe problem isn't with Parse. It's with how numbers are stored. You're using a division problem to generate a number which is infinitely long, 1.333333... A number like this is impossible to store accurately, so this is where your problem is created. In order to fix this, you'll have to round the results to the number of decimal places you need for accuracy. Also, use the Decimal type, not double. It's more accurate and all just about all the Math class methods support it directly with no conversions.
Math.Round[^] docs on MSDN.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|