|
Hi Everyone,
I am planning to buy C# book. I am bit confused whether to go for C# 3.0 book or C# 3.5 book. Please suggest me some good books on both.
Is there any major difference between c# 3.0 and 3.5?
Thanks & Regards
Guhan
|
|
|
|
|
Guhanath wrote: I am bit confused whether to go for C# 3.0 book or C# 3.5 book
Go for the C# 3.0 book as C# 3.5 does not exist.
However, you may have your terminology confused. Did you mean .NET 3.5?
The table in this blog post[^] might help.
|
|
|
|
|
Sorry for the confusion. It is .Net 3.5.which should i go? .Net 3.0 or 3.5?
|
|
|
|
|
Guhanath wrote: It is .Net 3.5.which should i go? .Net 3.0 or 3.5?
If you are using Visual Studio 2008 you have the option of using 3.5 and it will gracefully degrade to 3.0 or 2.0 if you want.
If you are using Visual Studio 2005 you only have the option of using 2.0 or 3.0 (with the Visual Studio extensions)
.NET 3.0 is additive. In other words, it does not change what was already in .NET 2.0 it only adds more to the .NET Framework.
.NET 3.5 is again additive. It only adds to what was in .NET 3.0 without changing anything that was already there.
|
|
|
|
|
Hello friends i am developing an windows application in C#.NET i want to align label text at run time according to user need.
i am using this command..
label1.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
but its gives an error....
|
|
|
|
|
1 - when you tell us you got an error, tell us what it was
2 - when you get an error, read it and see if you can work out what it says
3 - when you want to do something, read the MSDN instead of making stuff up.
this.lblBright.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
that's a line of code from my app. As you can see, and as the error is telling you, and as intellisense would also be making clear, the alignment is not set using the enum that you're trying to assign to it.
Christian Graus - Microsoft MVP - C++
"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 for solution and suggestion.
it works
Regards
Dikshant
|
|
|
|
|
Wrong enum. You can check the type by hovering your mouse over the word "TextAlign".
label.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
|
|
|
|
Hi Dikshant
Are you want to set by the code?
you can set easilly by the property window.
thanks
|
|
|
|
|
Hi all,
I wrote a C# .Net service to automatically do some process in each 10 seconds. Say I start the service at 10:10:10 hours, then process are executed at 10:10:10, 10:10:20, 10:10:30 ......and so on until I stop the service.
But I want to start the service at 10 seconds interval. That is either on 00, 10, 20, 30... seconds time. Not like 11, 34, 56....
In other words, even I start the service manually at anytime my processing should start like times on 10:20:00, 2:45:30, 11:19:50, etc
I think it is clear for you now.
All the things I start from the constructor method. May following code segment helps you...
namespace RfService
{
public class RfService : System.ServiceProcess.ServiceBase
{
public RfService()
{
InitializeComponent();
const double INTERVAL = 10000;
TimerTicker = new System.Timers.Timer( INTERVAL );
TimerTicker.Elapsed += new ElapsedEventHandler( this.ServiceTimer_Tick );
}
private void ServiceTimer_Tick( object sender, System.Timers.ElapsedEventArgs e )
{
}
}
}
Can you guys and gals give me a help to do it.
I appreciate your help all the time...
Eranga
|
|
|
|
|
The first time you set your timer, use DateTime.Now to make it fire on a 10 second interval. Then every time it fires, reset the interval in the last line of code, to keep that in sync.
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
You mean in constructor, do something like this before execute.
((DateTime.Now.Second % 10) == 0)
If the above condition is true then I can do the process, something like this.
public RfService()
{
InitializeComponent();
const double INTERVAL = 10000;
if((DateTime.Now.Second % 10) == 0)
{
TimerTicker = new System.Timers.Timer( INTERVAL );
TimerTicker.Elapsed += new ElapsedEventHandler( this.ServiceTimer_Tick );
}
}
If so, how can I check the each second from the starting time to start process.
Say current time is 12:00:01, then I have to work on that if loop until found 12:01:00. Now I'm really confusing how to deal with that every second.
I appreciate your help all the time...
Eranga
|
|
|
|
|
No, I meant if the time is 12:10:02, you set your timer for 8 seconds, so that when it fires for the first time, you're on the 10 second interval. But, I suggested you calculate that interval every time, b/c you don't know how long your code takes to execute ( and I have even less idea, I don't know what it does ), so you'd need the code to keep auto correcting to stay on the 10 second markers.
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
Christian Graus wrote: you don't know how long your code takes to execute
Yes, because of that time calculation can be going wrong. Thanks for the explanation.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Hi, i have a memory stick and store anyexe file in it. I'd like to know how to run exe file automatically in a stick when it is opening. Looking forward to ur reply. (email- zdliana@gmail.com)
zodingliana
|
|
|
|
|
Hi, i have a memory stick and store anyexe file in it. I'd like to know how to run exe file automatically in a stick when it is opening. Looking forward to ur reply.
|
|
|
|
|
You do that by putting an autorun.inf file on the memory stick.
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
How to disable Form close option (X Box).
Truth Is The Simplest !!!!
|
|
|
|
|
Handle the Closing event?
But, really, other than asking "Are you sure?" you should allow the user to close the application.
|
|
|
|
|
Why not just remove it ? You can do that in the form properties in the designer
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
ThankXXX..Christian Yes i want to remove but there is no property available.
If it is there pls let me know.
Truth Is The Simplest !!!!
|
|
|
|
|
It's the 'Control Box' option.
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
Removing the control box gets rid of minimize and maximize too.
This method just disables the close button and the Close menu item in the form's context menu. Make sure that you give the user a clean way to close the form though!
public Form1()
{
InitializeComponent();
EnableMenuItem(GetSystemMenu(this.Handle, false), SC_CLOSE, MF_GRAYED);
}
private const int SC_CLOSE = 0xf060;
private const int MF_GRAYED = 0x0001;
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern int EnableMenuItem(IntPtr hMenu, int uIDEnableItem, int uEnable);
Edit: I should add - to enable it again if you need to declare this constant:
private const int MF_ENABLED = 0x0000;
and the code to perform the enable is:
EnableMenuItem(GetSystemMenu(this.Handle, false), SC_CLOSE, MF_ENABLED);
Dave
modified on Friday, February 22, 2008 6:14 AM
|
|
|
|
|
Just tested it; it works, but Alt+F4 still closes the form.
|
|
|
|
|
Forgot that one! The code below handles that
private const int WM_SYSKEYDOWN = 0x0104;
private bool handleAltF4 = true;
protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
{
if (msg.Msg == WM_SYSKEYDOWN)
{
switch (keyData)
{
case System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.F4:
{
return handleAltF4;
}
}
}
return false;
}
Dave
|
|
|
|