|
will it become easy to use CompareTo in your case?
two DateTime object:
DateTime dt1 = new DateTime(2007, 10, 2);
DateTime dt2 = new DateTime(2007, 10, 22);
int result = dt1.CompareTo(dt2);
if (result == 1)
{
//dt1 is after dt2
}
else if (result == -1)
{
//dt2 is after dt1
}
else if (result == 0)
{
//dt1 is equal to dt2
}
|
|
|
|
|
That's because you are comparing the values as strings. If you just compare the DateTime values, it's not a problem.
---
single minded; short sighted; long gone;
|
|
|
|
|
if(DateTime.TryParseExact(fieldtext, DATETIMEPATTERN, null, DateTimeStyles.None, out doctime)) {
}
fieldtext is the string representation of the date eg "23/04/1978", DATETIMEPATTERN is the format "dd/MM/yyyy". doctime will contain a valid DateTime object if the method returns true.
For more info, check out the MSDN website.
A general hint, work with DateTime objects as much as possible and use the DateTime's ToString method at the very last moment...
good luck.
V.
No hurries, no worries
|
|
|
|
|
Is it possible to make aliases for elements in an XML Schema for Xsd.exe tool? I want to have localized elements/attributtes names in an XML file and english names in the generated code.
It would be also nice to have <summary> blocks in the generated code. I do not want to modify it manually because I update the schema and generate a new code sometimes. Is there some kind of 'comment' attribute or sth like that?
Maybe there is some free tool which would do these tasks for me, whatever. Please help.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
I have to embed multiple icons in my application so that windows can access it (i.e. Not as a managed resource). Is there any way to do it programatically/changing any prop settings of the project. Including the icons as 'embedded resource' will not help.
Now I am achieving this by opening the executable in VS IDE after building and manually adding the resource.
*jaans
|
|
|
|
|
Hello,
you can try the following C# compiler options
/win32res:<file> Specify a Win32 resource file (.res)
/win32icon:<file> Use this icon for the output
/resource:<resinfo> Embed the specified resource (Short form: /res)
/linkresource:<resinfo> Link the specified resource to this assembly
(Short form: /linkres)
Where the resinfo format is <file>[,<string
name>[,public|private]]
for more compiler options check the belwo link
http://msdn2.microsoft.com/en-us/library/2fdbz5xd(vs.80).aspx[^]
Cheers,
Suresh
|
|
|
|
|
Hi, i want to send & receive SMS in C# using USB Port , how i do this, it is good if you give me a code.
|
|
|
|
|
What makes you sure you can ? Do you mean the USB is used to connect to the phone ? If so, I don't get why you need to involve a PC at all. If not, from where do you hope to recieve SMS ? Is there an SDK for this, or are you just making it up ?
Sending SMS is possible through a number of webservice, easily found with google.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
What exactly are you trying to do. Explain your situation, what hardware you are using, etc...
I am using a gsm modem connected through a serial connection. With this gsm modem i send and receive sms messages.
|
|
|
|
|
Dear ALL,
I AM FACING PROBLEM I AM DEVLOPING DESKTOP APPLICATION NOW I WANT TO UPLODE THE FILES TO MY SERVER HOW CAN I DO THIS THING.
REGARDS
s REHMAN
|
|
|
|
|
Using FTP, IIS... or adding a shared folder on your server and adding on client computer
Visit my blog at http://dotnetforeveryone.blogspot.com/
|
|
|
|
|
Help me!!
I'm launching an external app using System.Diagnostics.ProcessStart() to download data from an inventory pistol. I can't integrate this app, I only can execute it. But my problem is that it download data from comm port, and when I launch it from windows all is fine and works, but when I start It from my app doesn't communicate. Seems that can open comm port.
Can somebody hel me?
Visit my blog at http://dotnetforeveryone.blogspot.com/
|
|
|
|
|
Some things to check:
1. How are you starting it outside of your application? If you are using a short-cut or a batch file, check to make sure you are using the same commad-line parameters.
2. I believe only 1 application can have the COM port open, so are you sure it's not already open when you launch it from your application?
3. Are you launching the application using the same credentials? If you are changing users in your application (using impersonation) or are launching your application as a different user, then maybe that person doesn't have rights. This includes rights to open the COM port and/or write to the "download" directory, if any.
4. Finally, as a test try launching it using a small test app that only starts the third-party app. This would help rule out ProcessStart as the culprit.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Hi,
How can I find all textbox in a form at runtime?
Thank you
|
|
|
|
|
By iterating over the controls collection of the form and check each control to see if it's a textbox
foreach(Control control in Controls)
{
TextBox tb = control as Textbox;
if (tb != null)
{
tb.Text = string.Empty;
}
}
An ASP.NET app would require a recursive solution.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
May still need to do a recursive for container such as panel, tablelayout, group, etc.
<br />
protected virtual void UnbindControls(Control control)<br />
{<br />
foreach (Control obj in control.Controls)<br />
{<br />
if (obj is Panel)<br />
{<br />
UnbindControls(obj);<br />
}<br />
else if (obj is GroupBox)<br />
{<br />
UnbindControls(obj);<br />
}<br />
else if (obj is TabControl)<br />
{<br />
UnbindControls(obj);<br />
}<br />
<br />
<br />
if (obj is TextBox)<br />
{<br />
}<br />
}<br />
}<br />
|
|
|
|
|
Good point.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have to make an application for windows as well as a same application for mobile. It is final project of my master degree and i m very confused to decide that which type of application should i have to design.
Ahmed
|
|
|
|
|
M. Ahmed wrote: It is final project of my master degree
You want to be easy...Windows. I would do it on mobile...but that's just me.
Do your best to be the best
|
|
|
|
|
Hi,
I am creating dynamic button and a textbox on my asp.net page on Page_load event.I am not able to raise event of button controll.Please guid me how can I perform any opration on click event of button.
{
TextBox TryTest = new TextBox();
Button btn = new Button();
TryTest.Font.Bold = true;
TryTest.ID = "Text1" ;
btn.ID = "Btn1";
btn.Attributes.Add("runat", "server");
btn.Attributes.Add("OnClick", "Button1_Click");
btn.Attributes.Add("Text", "Press Button");
PlaceHolder1.Controls.Add(new LiteralControl(" "));
TryTest.Text = "";
PlaceHolder1.Controls.Add(TryTest);
PlaceHolder1.Controls.Add(btn);
PlaceHolder1.Controls.Add(new LiteralControl(" "));
}
Girish Soni
|
|
|
|
|
This is not the ASP.NET forum.
You have to add your control before the page load event, in order for it to exist when viewstate is restored. Otherwise, your control is not there, and the viewstate is lost, including events.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
If you add OnClick as an attribute, it will just end up in the client code. It's only when you write it in the markup code that it is compiled into code that binds the event handler.
When you create the control dynamically, you have to write the code that binds the event handler yourself:
btn.Click += new EventHandler(Button1_Click);
The runat and Text attributes are also only used when you write the control in the markup code. If you add them as attributes, they will end up unchanged in the generated html code, where they have no meaning at all. Use the Text property of the control to set the text:
btn.Text = "Press Button";
---
single minded; short sighted; long gone;
|
|
|
|
|
i know it is simple but i am hang , i have an string to search in string i have to search digits and spe cial characters and alphabets how can i put condition in c Sharp in if condition.
i have use it before but now i forget the way how to search in a string.
|
|
|
|
|
Try using the Char class. It has some static functions that check if your character is a digit, letter and so on:
foreach (char c in s.ToCharArray())
{
if (Char.IsDigit(c))
{
Console.Write();
}
}
Do your best to be the best
|
|
|
|
|
You can use the Contains method of the strng class, or for more complex searches, use regular expressons, for example, you can use \d to search for any digit in a string, using regex.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|