|
If one were "better" than the other, one of both would be obsolete
If the value you're converting is NULL then Parse [^] will throw an exception, while ToInt32 [^] sets it to the number "0".
I are troll
|
|
|
|
|
OK, I agree your comments,but I concern mainly that which one is more performance efficient, espeically when such function is
used lot of times.
|
|
|
|
|
You should really only ever use TryParse unless you're *certain* there's a number in there. Both operations are costly, they both involve parsing the string and turning it into a number.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Hi,
Convert.ToInt32 is slower because it additonally checks the null value which int32.parse does not do. Checkout the Int32 function returned by .NET Reflector:
public static int ToInt32(string value)
{
if (value == null)
{
return 0;
}
return int.Parse(value, CultureInfo.CurrentCulture);
}
Convert.ToInt32 also uses int.parse internally. So int.parse is better as far as the performance is concerned. but it may throw exceptions if string value is not specified or an empty string is specified etc. I hope it helps.
Regards
Saank
Either you love IT or leave IT...
|
|
|
|
|
Great, thanks, this is what I want!
|
|
|
|
|
Great to know that this is what you wanted.
Regards
Saanj
Either you love IT or leave IT...
|
|
|
|
|
Hi,
I wan't to create a timer that starts at a given time! The start time will be set in a configuration file in a format HH:MM. After that the timer shall fire off with given intervals. The interval is configured in my configuration file in fomration HH:MM.
How can I do that?
/Håkan
|
|
|
|
|
What have you tried ? Amusingly enough, you will need a timer to check for the right time to start your actual timer, but beyond that, I don't see how this is at all hard.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Look at the System.Threading.Timer class.
You can specify an interval before the first execution and an interval between subsequent execution.
Keep in mind that the Timer class uses TimeSpans and not DateTimes. If you want to use specific times, you can do something like that:
DateTime startDate = DateTime.Today;
startDate.Hour = startHour;
startDate.Minute = startMinute;
TimeSpan interval = new TimeSpan(intervalHour, intervalMinute, 0);
Timer timer = new Timer(MyTimerCallback, null, startDate - DateTime.Now, interval);
|
|
|
|
|
Hello, I've been messing around with some code for a long time and haven't been able to figure out how do to this.. I've messed around with the System.Drawing.Bitmap, and bitmap graphics...
What I need is to get all of the images from a video file (i can do this myself, unless it's super easy to render every frame of an avi file?) and place each image on one large bitmap. Each image has to be converted to a power of 2 dimension (256x256, 512x256,1024x512, etc) and placed 1 blue pixel apart.
Here is an image example..
First image,
|
|
|
|
|
Ok, interesting problem, but I don't understand - what are you having trouble with? It looks like you're well on your way of finishing it
Is it just that the blue border is too big? (how did you make it?)
|
|
|
|
|
Oh, I'm sorry. I need help with code to do that, That was just an example of what needs to happen.
And here is code in VB i was working with awhile back, i'm not sure if it was ever finished.. loaded up in visual studio gives me the error
Error 1 Overload resolution failed because no accessible 'DrawImage' can be called with these arguments:
'Public Sub DrawImage(image As System.Drawing.Image, x As Integer, y As Integer)': Value of type 'System.Drawing.Brush' cannot be converted to 'System.Drawing.Image'.
'Public Sub DrawImage(image As System.Drawing.Image, x As Single, y As Single)': Value of type 'System.Drawing.Brush' cannot be converted to 'System.Drawing.Image'. N:\XP\My Docs\My Documents\Visual Studio 2008\Projects\HaloVideo\****Video\Form1.vb 12 9 ****Video
Dim img3 As New Bitmap(PictureBox1.Image.Height + PictureBox2.Image.Height, PictureBox1.Image.Width)
Dim g As Graphics = Graphics.FromImage(img3)
g.DrawImage(Brushes.Blue, 0, 0)
g.DrawImage(PictureBox1.Image, 0, 0)
g.DrawImage(PictureBox2.Image, PictureBox2.Image.Width + 1, 0)
PictureBox3.Image = img3
But i need for C#, and i need it to actually do what i want it to do. lol
I guess a way would to possibly have a blue background graphic and then overlay images ontop of it with 1 px distance from eachother?
|
|
|
|
|
Sounds trivial to me. What have you tried ? Why are you creating bitmaps that are too big, if you only want one pixel borders ?
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Hello,
I have created a vbscript called sample.vbs
This file contains a simple script to create a Test.Log file on the C drive of the target machine. This script works as it has been tested.
The code below runs the script (sample.vbs) located on mylocalmachine against a remote machine i.e. Servermachine
There is no error but the file i.e. Test.Log does not appear in the c drive of the target machine i.e. Servermachine
please note that if I make the target machine as the local machine i.e. myLocalMachine then the Test.Log file does appear in the c drive.
Question:
can you please let me know why this code does not create the file on the target machine?
The vbscript in sample.vbs in case you are interested is shown at the bottom of this message.
Thank you
try
{
string stringCommandLine = @"cscript.exe \\myLocalMachine\c$\work\sample.vbs";
System.Management.ManagementOperationObserver observer = new System.Management.ManagementOperationObserver();
System.Management.ConnectionOptions conn = new System.Management.ConnectionOptions();
conn.Impersonation = ImpersonationLevel.Impersonate;
conn.EnablePrivileges=true;
conn.Authentication=AuthenticationLevel.Default;
System.Management.ManagementScope ms = new System.Management.ManagementScope("\\\\" + "Servermachine" + "\\root\\cimv2", conn);
//System.Management.ManagementScope ms = new System.Management.ManagementScope("\\\\" + "myLocalMachine" + "\\root\\cimv2", conn);
ms.Connect();
System.Management.ManagementPath path = new System.Management.ManagementPath("Win32_Process");
System.Management.ManagementClass processClass = new System.Management.ManagementClass(ms, path, null);
object[] methodArgs = { stringCommandLine, null, null, 0 };
uint result = (uint)processClass.InvokeMethod("Create", methodArgs);
}
catch (ManagementException err)
{
MessageBox.Show("An error occurred while trying to execute the WMI method: " + err.Message);
}
catch (System.UnauthorizedAccessException unauthorizedErr)
{
MessageBox.Show("Connection error (user name or password might be incorrect): " + unauthorizedErr.Message);
}
///////////////////////////
////sample.vbs
Dim fso ' FileSystemObject
Dim f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.CreateTextFile("c:\test.log", True, True)
f.WriteLine("This is generated by test.vbs at " & Now)
f.Close()
|
|
|
|
|
Hello Experts!!
I am scanning barcode and display it into grid cell,Now i want to check that barcode is already present or scanned in same grid.I am not saving data into database.
So please suggest me event for same action.
e.g.
no. name address
1 kidya U.S.
2 Sam U.K.
if i scan 1 again then it must show msg "No. already scanned"
|
|
|
|
|
So before you add a scan you loop through the existing row/cells and check for existing records.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
tell me event for that.i tried in cellEnter and cellLeave event but didn't work.
|
|
|
|
|
How are you adding the records
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: Never underestimate the power of human stupidity
You've ignored your own warning!
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Slow afternoon and I've brick walled it with some WCF I'm fighting.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I prefer the original: Soha alábecsül a erő -ból emberi butaság
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
i am just scanning barcode then according to same barcode i am fetching record from sql and then show it on grid cell.So i want to ignore duplicate records.
|
|
|
|
|
No, he's not suggesting hooking into an event.
BEFORE adding a new row, ITERATE through the current content and CHECK for the DUPLICATE.
Now, somewhere you have a line of code along the lines of:
Wibble hatstand = barcode.Read();
!! CHECK HERE !!
dataGrid.Add(hatstand);
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Hi,
I'm really hoping for an easy answer to this issue. I have a client device that uses a hardwired connection to communicate with its server if it is in a docking station. If lifted from the docking station the hardwired connection is disabled and it switches to its wireless connection. This is where remoting stops working on the serverside.
The client device has 2 network cards with different IPs, one for the hardwired connection and one for the wireless connection. When switching to wireless/hardwired the client is still able to send messages to the server, but apparently the server is still trying to reach the client on the connection it initially used so the return messages fail.
How is this fixed? Where is this fixed? I've tried to call RemotingServices.Configure again but it seems you can only call that once. Unregistering and re-Registering channels doesn't seem to work either. Any ideas would be greatly appreciated! Solutions even more!
|
|
|
|
|
Dear all,
I have 2 forms. When I click a button on 1 form, other form will draw something. However, it is seemly that OnPaint method is not called. Please tell me the way to do it.
Thanks
あんかた
|
|
|
|