|
stephan_007,
Why would you want to do this? there are already methods in place to do this.
Regards,
Gareth.
|
|
|
|
|
Why take a string as input? Even an object would be better:
if ( input is int ) ((int) input).ToString ( formatstring ) ;
else if ( input is System.DateTime ) ((System.DateTime) input).ToString ( formatstring ) ;
But would calling the appropriate ToString directly help?
someint.ToString ( "#,##0.0000" ) ;
somedate.ToString ( "dd/MM/yyyy" ) ;
(Of course, I also have to recommend that you use an ISO 8601 date format like "yyyy-MM-dd".)
|
|
|
|
|
i parse from a textfile which contains infos like
|value|{#,##0.0000}
|date|{0:dd/MM/yyyy}
when parsing the tokens (a token is e.g. |value|) is replaced by it's value and formated by the formatstring behind. so i parse the string after the token and format the string with this formatstring.
so the input is always a string.
i do also provide the culture info which corresponds to the string format so it is formated correctly.
<br />
input.ToString(FormatString, new CultureInfo(LocalString));<br />
|
|
|
|
|
Sounds like a bad design; go slap the person responsible.
Why doesn't the system that writes the file perform the format?
|
|
|
|
|
Hi frnds,
I am working with System.Timers.Timer
I have configured timer to trigger every 60 mins, its working fine on my machine but getting triggered every 7 minutes on server.
Is it an issue with the Timer class? I dont see any reason for this to happen...
Keep DotNetting!!
GeekFromIndia
|
|
|
|
|
Could you please post some code?
that would help to resolve your issue..
|
|
|
|
|
With a long cycle like that I'd just use a Scheduled Task.
|
|
|
|
|
60 minutes or 60 seconds?
|
|
|
|
|
I wouldn't set up a timer with an interval as large as 60 minutes, or any minutes really. If you need to use a timer, set it up to fire every second, and count the time yourself. There's a couple of ways you can check how much time has passed, and here they are:
int counter = 0;
void Timer()
{
if(counter == (60*60)) {
its been a hour, omg!
counter = 0;
}
}
And i prefer this way, since you don't have to increase a counter yourself
DateTime now = DateTime.Now;
DateTime start = DateTime.Now;
void Timer()
{
TimeSpan huh = start-now;
if(huh.Hours >= 1) {
Its been an hour, again!
start = DateTime.Now;
}
}
I'm sure there are other things you can do instead of using a timer, but if you have to...
My current favourite word is: Bacon!
-SK Genius
|
|
|
|
|
Thanks guys,
Sorry i was busy whole day to check your replies. Dont really know what was the problem but after reinstalling the msi it started working correctly.
SK,
Your suggestion looks interesting but i dont see any reason to do this.
Why would i like to trigger an event every second when it to take a rest for an hour??
Thanks.
Keep DotNetting!!
GeekFromIndia
|
|
|
|
|
Hi guys,
Please help! I am trying to show an animated gif on button click. in my click event I have a while loop and until the while loop condition is met I would like to show an animated gif to inform the user that the application is searching...
I have tried different methods, threads, a new form with the picturebox and image and all of them show the image but the transition/rotation of the image is not smooth. Please help on how to go about this.
Thank you in advance
Sameer
|
|
|
|
|
Sounds like your search needs to go into another thread, so that the gif code can run smoothly.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks Christian for your response. Can you please give me an example or something, I am quite new to threading. Thanks in advance.
Sameer
|
|
|
|
|
BackgroundWorker[^] is the class I use for threading.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thank you Christian. I will give this a shot.
Sameer
|
|
|
|
|
Have you already tried to use the ImageAnimator class?
|
|
|
|
|
no I haven't, it required me to change quite a bit of my code so I have left it for now. I wish there was an easier solution
Sameer
|
|
|
|
|
I have an application which is launched to run as different user than logged in user.
When user start shutdown/restrat/loggoff I don't receive WM_QUERYENDSESSION. I tried running the same process with logged in user and it works fine.
When it is running as different user, it doesn't even receive FormClosing. I think its directly killed.
How do I resolve this problem? Please help.
Thanks in advance
Shanti
|
|
|
|
|
I'm making a class called MMap (Modifiable Map), it's similar to System.Collections.Generic.Dictionary, except you can modify the value of the given key. What I want to do is make sure that typeparam K is always a nullable type, IE not primitives like int or char. I know I have to do something like this:
public class MMap[K, V] where K : foo<br />
{<br />
<br />
}
but I'm not sure what to put where foo is. I'm using .Net 2.0 (I know the [] should be less than and greater than)
Thanks.
|
|
|
|
|
Something like this can make a similar behavior:
public class MMap< K,V > where K:struct
{
public void Add(Nullable < K > key,V value)
{
}
}
|
|
|
|
|
hspc wrote: where K:struct
where K:class
|
|
|
|
|
PIEBALDconsult wrote: where K:class
This will cause a compilation error, Nullable accepts structs only.
|
|
|
|
|
"
a nullable type, IE not primitives like int or char
"
and he said "nullable", not "Nullable".
|
|
|
|
|
|
I've create a setup project with c#.NET 2008 and i need to run a bat file after the installation is completed. So, how to set my setup project to run bat file after installation?
thank
a
|
|
|
|