|
I have a file that has informatin separated by (;) as follow
colors;serverName1;size;location
colors;serverName1;size;location
colors;serverName1;size;location
I want to read the servername (after the fist and last ";" )
any ideas how to do this?
thank you in advanced
PS
|
|
|
|
|
You can determine the index of the semicolons using the String.IndexOf method and then retrieve the server name by using the String.Substring method.
Alternatively, you can split the string using the String.Split method and the semicolon as delimiter and access the proper item of the returned array.
"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." - Rick Cook www.troschuetz.de
|
|
|
|
|
String.Split is your friend.
Luc Pattyn
|
|
|
|
|
for the following:
float x = (38.40f * 1000.0f) - 32435.0f;
I get x = 5965.00146.
Surely floats are more accurate than this, or is there a problem I'm not seeing?
John Acton
|
|
|
|
|
No this is normal behavior for floats; their size is 32-bit, of which they use about 24 bits
for their mantissa, which amounts to about 7 decimal digits.
If you want more precision, use double; their size is 64-bit, the mantissa uses about 56 bits,
they can hold about 16 decimal digits.
If memory efficiency is important, you may want to store floats, but do intermediate calculations
with doubles.
If your application is financial (or anything else with a limited maximum value, that
requires accurate fractional digits) consider the decimal type.
BTW similar considerations exist in whatever programming language you choose...
Luc Pattyn
|
|
|
|
|
Thanks for your help.
John Acton
|
|
|
|
|
|
|
I have table1 which has the columns:
A,B,C,D,E
I have table2 which has the columns:
E,F
My end result is that I want to only export the data from table1 - Column E
I could go through a foreach loop for each row on table1 and if it exists on table2, then write it out, but is there a quicker way to do this ?
Thank you
|
|
|
|
|
Where are the tables ? You can get the list of items using a simple SQL statement.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
The columns we are interested in are from a schema file, which is dumped into a datatable and these are the columns we need.
|
|
|
|
|
|
Is there an equivelant to the VB #import?
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
What does #import do ?
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
sorry about that its the "imports" command. What i have is a class with a bunch of static methods. What i normally would do is something like this: ClassOne.MethodOne. Someone told me in VB you could use an "imports" command to import the entire class so you could just call the methods themselves without typing in the class name. Is there something like that out there like that for C#?
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
No, that really sucks, and C# doesn't do it, AFAIK.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
I must admit that I learned #import in C/C++ only. The equivalent in VB.NET is Imports, and the c# equivalent is using.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
In VB you are able to import a class instead of just a namespace. is there any way to do this in C#? I tried to import a class and it won't let me.
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
now why in the world would you want to "import" a class instead of a namespace?? That would make all of the fields of the "imported" class fields of the "importing" class. ...What you are describing is inheritance. Look here http://msdn.microsoft.com/library/en-us/vbls7/html/vbSpecStart.asp
Allowing what you are requesting would break object oriented design
(Nyquist Rate || ! Nyquist Rate)
{
Console.WriteLine("That is the question");
}
|
|
|
|
|
You can apply 'using' to a class if you use an alias:
e.g.,
using filealias = System.IO.File;
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter, VB to C++ converter
Instant Python: C# to Python converter, VB to Python converter
|
|
|
|
|
using is only for namespaces, not to bring a class into scope, or is it ?
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Yes. You can do:
using System.Windows.Forms;
using Timer=System.Threading.Timer;
namespace xx {
class yy {
Timer timer=new Timer();
}
}
Luc Pattyn
|
|
|
|
|
Oh, I knew that. He wants to do this
using System.IO.Path;
class x
{
void somemethd(path)
{
string ext = GetExtension(path);
}
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
yeah basically i have a namespace called UVNET and i have a class called UniArray in that class has a bunch of static methods (one being called Extract) what Extract does is returns a string. Instead of doing
string myName = UniArray.Extract(someString, 2);
i would like to do
string myName = Extract(someString, 2);
a co-worker works with VB and said that instead of Importing just the namespace (i.e Imports UVNET) he can actually import the class also (i.e. Imports UVNET.UniArray) so he can just use the functions without calling the class over and over again. I was just wondering if there was a way that it was possible with C#. I mean its no big deal really it would just make the code look cleaner if i didn't have "UniArray" all over the place. This class has about 25 funcions that i use regularly and to me it would be easier if i could just type in the method itself
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
Here[^] is a link to a screen capture i took while doing it in VB so you could see what's actually going on.
-- modified at 21:20 Monday 29th January, 2007
Don't be overcome by evil, but overcome evil with good
|
|
|
|