Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

c# syntax

  Asked By: Violet    Date: Jun 06    Category: Asp.net    Views: 947

few ones:
1.how can i declare (in c#) about multiple cases inside switch?
in vb
select case bla
case 10,20,40,50
bla bla
end select

2.what is the equivalent to
Object = nothing

3.i got error:
strArry = fileName.Split(Convert.ToChar("."));

response.write (strArray[1])

error : cannot apply indexing [] to system.array

4.how can i "exit sub" in c#



16 Answers Found

Answer #1    Answered By: Elias Turner     Answered On: Jun 06

1:supress the break keyword like:
int var = 1;
case 0:
case 1:
case n:
//your stmt goes here;
case 23:
2: Object = null;
3: try put .ToString after the index.
4: your can use return keyword.
hope it helps

Answer #2    Answered By: Kifah Malik     Answered On: Jun 06

except that
3.i got error:
strArry = fileName.Split(Convert.ToChar("."));

response.write (strArray[1])

error : cannot apply indexing [] to system.array

not working...

Answer #3    Answered By: Vicki Fields     Answered On: Jun 06

string[] strArray = new string[]

its an array !

& just use Split('.');

dont't think you convert strings to chars somehow !

Object = null;

Answer #4    Answered By: Isra Demir     Answered On: Jun 06

sorry but it still doing prob.
i have quite a lot of expiernce in vbscript/vb6/vb.net
but totally beginner to c#:

string[] strArray = new string[];

strArry = fileName.Split(".");

string fileExtension = strArry[1];



case "gif":


Answer #5    Answered By: Abrianna Rossi     Answered On: Jun 06

str = "abc,def,ghi,jklm,no,pq,rstuvw,xyz";

string[] s = str.Split(',');

for (int i =0; i<s.Length;i++)


Response.Write(s[i] + "<br>");


Answer #6    Answered By: Damon Jones     Answered On: Jun 06

I wouldn't use what you are doing with fileextensions - there are
methods in .NET to do that

what if you had a file called "my.filename.ext" which is quite reasonable ...
and common ... people tend to rename things by adding an extension to them,

e.g. global.aspx -> global.aspx.old

Answer #7    Answered By: Varun Mehta     Answered On: Jun 06

I see your point
string[] strArray = new string[]
is invalid as the array is not initialised.

I have a question :: In .NET is there a Vector array or equivalent ? i.e. an
array that grows or do we have to use ArrayList or make our own ???

Answer #8    Answered By: Vidhya Iyer     Answered On: Jun 06

u r right...
let me ask u another little thing:
myUpload.uploadPath = "c:\http\filesUpload\files\";

error: unrecognized escape sequance...

Answer #9    Answered By: Alvin Nguyen     Answered On: Jun 06

Use \\, since \ in a string needs a escape sequence.

Answer #10    Answered By: Jackson Bouchard     Answered On: Jun 06

what error  do you get? Index does not exist or anything else?

Answer #11    Answered By: Isaac Williams     Answered On: Jun 06

Wrong array declaration. Actually I haven't seen any declaration for your
strArray. Declare as this:

//use single quote for char - you don't have to use Convert class...
string[] strArray = fileName.Split('.');

This SHOULD work. I used it a hundred times...

Answer #12    Answered By: Luki Fischer     Answered On: Jun 06

don't know why your switching to C#, it was supposed to be the new thang, but as
time has gone by it is VB that has taken a hold more than anything else. All
jobs around my area recently are only interested in VBers.
C# was supposed to pull in the java boys - but they ain't shifting.
The C++er's have managed C++, but they seem to like C# better; but to them its
just another library they can use ... usually when performance isn't an issue
... it will never replace native code for them.

Its the VBer who HAVE to switch, thus gaining web skills and making direct
competition for java, thus spreading IIS , etc, etc, etc. It's server market
share is what MS want.

Answer #13    Answered By: Dennis Hayes     Answered On: Jun 06

I just looked at


I'm afraid you have bigger problems than the ones you are suffering, your whole
website is upside down !

Answer #14    Answered By: Canan Kaya     Answered On: Jun 06

because the vice manager of our company wants we will write  in c#.
i beg to him and wanted the familier vb...
anyway whats wrong in the site?
upside down?it's hebrew site.

Answer #15    Answered By: Steve Boyd     Answered On: Jun 06

When you get used to C# you'll never think of vb again. My college at work
swithed in one week and begins to like it very much...

Answer #16    Answered By: Raul Clark     Answered On: Jun 06

I never thought of it to begin with.
(except when asp MADE me).

I agree with Robert, C# is better than VB
Think of it this way Elad .... for string length n
in VB you can have 26^n combinations (letters only)
But in C# you can have 52^n = (26^n)*(2^n)
so 2^n times as many strings available to you ... that's gotta make it better
hasn't it ?

Didn't find what you were looking for? Find more on c# syntax Or get search suggestion and latest updates.