|
in C# Windows Console Application how do i convert number String (for example: "16.3") to Float so that i can do later calculations on? whats the code ?
tx
|
|
|
|
|
float f = Single.Parse("16.3", CultureInfo.InvariantCulture);
---
single minded; short sighted; long gone;
|
|
|
|
|
thanks for your quick efficient help
|
|
|
|
|
You can always use float.parse(variable)
Regards,
Jaiprakash M Bankolli
jaiprakash.bankolli@gmail.com
http://jaiprakash.blog.com/
|
|
|
|
|
I'd prevere double.TryParse method.
This prevents you of an exception if the sring is not a number.
All the best,
Martin
|
|
|
|
|
Which are the differences between .NET 2.0 y .NET 3.0? Is recommended to use .nEt 3.0?
Best regards Borja
|
|
|
|
|
.NET 3.0 is not really a full version update, it's just .NET 2.0 with some added features. Framework 3.0 will not come until .NET 3.5.
If you want to try out the new features, you can install .NET 3.0, but it will not install any new version of the framework if you already have framework 2.0.
---
single minded; short sighted; long gone;
|
|
|
|
|
The .NET 3.0 is basically the same as .NET 2.0 except it also adds WPF, WCF, and Cardspace to the framework (I may be missing a category). .NET 3.0 is part of the foundation of Windows Vista and is not widely used on Windows XP or earlier computers so I would not use .NET 3.0 unless it is absolutely needed or if the target machine is running Windows Vista. In another year or so the .NET 3.0 may become the standard on all computers, but until then use it sparingly.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Hi, I have many timers in my code also I have Serialport.data.received event, I wana set priority for them.
very tanx
hasi
hasi27
|
|
|
|
|
|
hasi27 wrote: I wana set priority for them.
What do you mean by priority? Simply setting a timer's tick to a lesser value makes it execute more often.
|
|
|
|
|
Hi,
I would say you cant set priority for the normal timer events:
all Windows.Forms.Timers get their event handled by the UI thread, hence at the same priority; it is unclear (I guess unspecified) in which order they would fire assuming
more than one of the timers is supposed to fire at a specific point in time
(maybe you will find my timers article interesting, it tells you more about the
resolution of the timer classes).
all other timers (Windows.Threading.Timer and Windows.Timers.Timer), as well as other
asynchronous events, typically use their own thread to service the event.
Here too, you typically dont control the thread's priority,
and the order of concurrent events is unspecified.
of course, you could organize a periodic event at a higher priority by using
your own thread, set at higher (maybe real-time) priority, and using a high-precision
timer (again see my article).
Hope this helps.
|
|
|
|
|
i have in a textbox "1+2+3". How can i convert this string to find the result aka 6 ?
|
|
|
|
|
"1+2+3" from the textbox is just a string. How to interpret it is entirely up to you. So, in order to obtain the result, you need to write your own parsing rules and calculating logic.
Best,
Jun
|
|
|
|
|
ok! But how could i interpret "+" like + operator ?
I am thinking to split the string "1+2+3", 1,2 and 3 are numbers, integer, but "+" what type it is?
|
|
|
|
|
That type of string can be split to two categories: operands and operators. Operands are simply numbers. With operators, you cast them one by one. Pseudo code may be like this:
switch(operator1)
{
case "+":
result = operand1+operand2;
break;
case "-":
result = operand1-operand2;
break;
}
I am not aware of any shortcuts in this regard.
Best,
Jun
|
|
|
|
|
First you need to split "+" into an array
Then each of the array value needs to be converted or Parsed and added
Regards,
Jaiprakash M Bankolli
jaiprakash.bankolli@gmail.com
http://jaiprakash.blog.com/
|
|
|
|
|
|
|
This is probably very simple but im having trouble getting my head around it.
Ive tried making a temporary list view item which stores the selected list view item,
Then move the selected list view item + 1 up one,
Then the selected list view item + 1 = the temporary,
But i keep getting errors.
Can anyone help me?
|
|
|
|
|
Hi, what is the View (LargeIcon, Details, ...) ?I have some experience with setting
icon positions on the desktop, which is a listview with View=LargeIcon.
|
|
|
|
|
|
Can you send me your code so that we can pin point the error !!
Regards,
Jaiprakash M Bankolli
jaiprakash.bankolli@gmail.com
http://jaiprakash.blog.com/
|
|
|
|
|
Here is my code, im not sure if im even tackling this problem correctly.
<br />
private void listView1_KeyDown(object sender, KeyEventArgs e)<br />
{<br />
if (e.KeyValue == 40)<br />
{<br />
ListViewItem temp = new ListViewItem();<br />
ListViewItem temp2 = new ListViewItem();<br />
for (int i = 0; i < listView1.SelectedIndices.Count; i++)<br />
{<br />
if(listView1.SelectedItems[i].Index + 1 <= listView1.Items.Count)<br />
{<br />
temp = listView1.Items[listView1.SelectedItems[i].Index + 1];<br />
temp2 = listView1.Items[listView1.SelectedItems[i].Index];<br />
<br />
listView1.Items[listView1.SelectedItems[i].Index + 1] = temp2;<br />
listView1.Items[listView1.SelectedItems[i].Index] = temp;<br />
}<br />
}<br />
}<br />
}<br />
|
|
|
|
|
Hi,
there is a bug: if the last listview item is selected (the one with index=count-1),
then temp will refer to the one with index=count, which exceeds the array.
there probably is a second bug: if items 2 and 3 are selected, then maybe
first 2 and 3 get swapped, then 3 and 4 get swapped, which might not be what
was intended.
index 0 1 2 3 4 5
So original A B C D E F
becomes A B D C E F
then A B D E C F
Also I am not sure the items in SelectedItems are in numerical
order, in selection order, or random order.
Furthermore, there is no need to create new ListViewItems (temp, temp2).
Hope this helps
-- modified at 3:39 Monday 16th April, 2007
|
|
|
|