By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,187 Members | 1,513 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,187 IT Pros & Developers. It's quick & easy.

ADO C# VB Difference

P: n/a
In vb we say....

Dim theRow As dsLogin.CustLoginRow
theRow = DsLogin1.CustLogin.Rows(0)

If I try to say the following in C# it says I can't do an implicit
conversion...

dsLogin.CustLoginRow theRow;
theRow = dsLogin1.CustLogin.Rows[0];

So I had to say......

dsLogin.CustLoginRow theRow;
theRow = (dsLogin.CustLoginRow) dsLogin1.CustLogin.Rows[0];

that's pretty wordy. Is there a better way to say this in C#?

Thanks again (and sorry for so many quesions)
T
May 13 '06 #1
Share this Question
Share on Google+
10 Replies


P: n/a
No. That's the way to do it.
--

Cheers,
Gaurav
http://www.edujini.in
-------------------
"Tina" <ti**********@nospammeexcite.com> wrote in message
news:ez****************@TK2MSFTNGP05.phx.gbl...
In vb we say....

Dim theRow As dsLogin.CustLoginRow
theRow = DsLogin1.CustLogin.Rows(0)

If I try to say the following in C# it says I can't do an implicit
conversion...

dsLogin.CustLoginRow theRow;
theRow = dsLogin1.CustLogin.Rows[0];

So I had to say......

dsLogin.CustLoginRow theRow;
theRow = (dsLogin.CustLoginRow) dsLogin1.CustLogin.Rows[0];

that's pretty wordy. Is there a better way to say this in C#?

Thanks again (and sorry for so many quesions)
T

May 13 '06 #2

P: n/a
I suppose you could shave off a line:

dsLogin.CustLoginRow theRow= (dsLogin.CustLoginRow)
dsLogin1.CustLogin.Rows[0];

Actually, if you think C# is "Wordy", try counting the number of characters
in an entire Class written in VB.NET and then the same one in C#. Most of the
time, C# is more compact. It certainly is more elegant, although that of
course is just my opinion.

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Tina" wrote:
In vb we say....

Dim theRow As dsLogin.CustLoginRow
theRow = DsLogin1.CustLogin.Rows(0)

If I try to say the following in C# it says I can't do an implicit
conversion...

dsLogin.CustLoginRow theRow;
theRow = dsLogin1.CustLogin.Rows[0];

So I had to say......

dsLogin.CustLoginRow theRow;
theRow = (dsLogin.CustLoginRow) dsLogin1.CustLogin.Rows[0];

that's pretty wordy. Is there a better way to say this in C#?

Thanks again (and sorry for so many quesions)
T

May 13 '06 #3

P: n/a
Thanks. That's a little better.

Regarding your preference for C#....

IMHO, I have never seen two languages more on par with each other. The
great mistake is that they both exist and therefore there is this difference
thing. Microsoft should have flipped a coin and just put all of there
resources on either one of them.

T


"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:E9**********************************@microsof t.com...
I suppose you could shave off a line:

dsLogin.CustLoginRow theRow= (dsLogin.CustLoginRow)
dsLogin1.CustLogin.Rows[0];

Actually, if you think C# is "Wordy", try counting the number of
characters
in an entire Class written in VB.NET and then the same one in C#. Most of
the
time, C# is more compact. It certainly is more elegant, although that of
course is just my opinion.

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Tina" wrote:
In vb we say....

Dim theRow As dsLogin.CustLoginRow
theRow = DsLogin1.CustLogin.Rows(0)

If I try to say the following in C# it says I can't do an implicit
conversion...

dsLogin.CustLoginRow theRow;
theRow = dsLogin1.CustLogin.Rows[0];

So I had to say......

dsLogin.CustLoginRow theRow;
theRow = (dsLogin.CustLoginRow) dsLogin1.CustLogin.Rows[0];

that's pretty wordy. Is there a better way to say this in C#?

Thanks again (and sorry for so many quesions)
T

May 13 '06 #4

P: n/a
"Tina" <ti**********@nospammeexcite.com> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
IMHO, I have never seen two languages more on par with each other. The
great mistake is that they both exist and therefore there is this
difference thing. Microsoft should have flipped a coin and just put all
of there resources on either one of them.


LOL! I guess you don't work in marketing... :-)
May 13 '06 #5

P: n/a
I am proud to say that I certainly don't work in Marketing (I passed
calculus).

I suppose you think that SUN should have brought out another language in
addition to JAVA. Maybe they would have called it COCO - it would do the
same thing as JAVA but be syntactically different in most every way so
everyone would have to learn two languages.

T :)
"Mark Rae" <ma**@markN-O-S-P-A-M.co.uk> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
"Tina" <ti**********@nospammeexcite.com> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
IMHO, I have never seen two languages more on par with each other. The
great mistake is that they both exist and therefore there is this
difference thing. Microsoft should have flipped a coin and just put all
of there resources on either one of them.


LOL! I guess you don't work in marketing... :-)

May 14 '06 #6

P: n/a
Marketing is correct; VB.NET exists almost entirely because of marketing.
Almost everything in the .NET Framework, including all of ASP.NET, is written
in C#. C# was designed by Anders Hejlsberg and his team as the original,
target language for the .NET Platform.
VB.NET had to come along for the ride because there are (were) 10 times more
VB Classic programmers than potential C# programmers, and MS could not simply
leave them in the lurch vis-a-vis .NET.

If VB.NET programmers would turn on Option Explicit and Option Strict, and
stay away from the Microsoft.VisualBasic namespace and all its "Classic VB
Crutch" methods and classes, and simply use the ones built into the Base
Class Library, then you'd have a chance of being correct in saying the two
languages are on a par with each other.

Pointer arithmetic and unsafe code, not.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Tina" wrote:
I am proud to say that I certainly don't work in Marketing (I passed
calculus).

I suppose you think that SUN should have brought out another language in
addition to JAVA. Maybe they would have called it COCO - it would do the
same thing as JAVA but be syntactically different in most every way so
everyone would have to learn two languages.

T :)
"Mark Rae" <ma**@markN-O-S-P-A-M.co.uk> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
"Tina" <ti**********@nospammeexcite.com> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
IMHO, I have never seen two languages more on par with each other. The
great mistake is that they both exist and therefore there is this
difference thing. Microsoft should have flipped a coin and just put all
of there resources on either one of them.


LOL! I guess you don't work in marketing... :-)


May 14 '06 #7

P: n/a
Not to drag on this point but....

What are the "Classic VB Crutch Methods" that you refer to?
Thanks,
T

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:B2**********************************@microsof t.com...
Marketing is correct; VB.NET exists almost entirely because of marketing.
Almost everything in the .NET Framework, including all of ASP.NET, is
written
in C#. C# was designed by Anders Hejlsberg and his team as the original,
target language for the .NET Platform.
VB.NET had to come along for the ride because there are (were) 10 times
more
VB Classic programmers than potential C# programmers, and MS could not
simply
leave them in the lurch vis-a-vis .NET.

If VB.NET programmers would turn on Option Explicit and Option Strict, and
stay away from the Microsoft.VisualBasic namespace and all its "Classic VB
Crutch" methods and classes, and simply use the ones built into the Base
Class Library, then you'd have a chance of being correct in saying the two
languages are on a par with each other.

Pointer arithmetic and unsafe code, not.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Tina" wrote:
I am proud to say that I certainly don't work in Marketing (I passed
calculus).

I suppose you think that SUN should have brought out another language in
addition to JAVA. Maybe they would have called it COCO - it would do
the
same thing as JAVA but be syntactically different in most every way so
everyone would have to learn two languages.

T :)
"Mark Rae" <ma**@markN-O-S-P-A-M.co.uk> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
> "Tina" <ti**********@nospammeexcite.com> wrote in message
> news:%2****************@TK2MSFTNGP05.phx.gbl...
>
>> IMHO, I have never seen two languages more on par with each other.
>> The
>> great mistake is that they both exist and therefore there is this
>> difference thing. Microsoft should have flipped a coin and just put
>> all
>> of there resources on either one of them.
>
> LOL! I guess you don't work in marketing... :-)
>


May 14 '06 #8

P: n/a

Tina wrote:
Not to drag on this point but....

What are the "Classic VB Crutch Methods" that you refer to?


He's referring to the Microsoft.VisualBasic namespace, and the stuff
therein. However, I would disagree with the 'crutch' characterization -
the VB namespace functions generally do things in a more 'Basic-like'
way.

For example, this namespace contains a Left function, for taking the
left n characters of a string - C#ers would do this with
String.Substring. However, Left includes additional sanity checks, as
shown by this Reflector output:

public static string Left(string str, int Length)
{
if (Length < 0)
{
throw new
ArgumentException(Utils.GetResourceString("Argumen t_GEZero1",
"Length"));
}
if ((Length == 0) || (str == null))
{
return "";
}
if (Length >= str.Length)
{
return str;
}
return str.Substring(0, Length);
}
Now, the C# 'attitude' would be to say that, for example, anyone who
asks for the left 6 characters of a 3 character string, or the left 4
characters of a null string variable, deserves everything they get. The
VB 'attitude' is that the former should get the string itself, and the
latter should get an empty string

Anycode using the Microsoft.VisiualBasic.Compatibility namespace, on
the other hand, should be rewritten asap.

--
Larry Lard
Replies to group please

May 15 '06 #9

P: n/a

Tina wrote:
In vb we say....

Dim theRow As dsLogin.CustLoginRow
theRow = DsLogin1.CustLogin.Rows(0)
Hmm, a strongly typed dataset, or no?

If I try to say the following in C# it says I can't do an implicit
conversion...

dsLogin.CustLoginRow theRow;
theRow = dsLogin1.CustLogin.Rows[0];

So I had to say......

dsLogin.CustLoginRow theRow;
theRow = (dsLogin.CustLoginRow) dsLogin1.CustLogin.Rows[0];

that's pretty wordy. Is there a better way to say this in C#?


So it's not a strongyly-typed dataset. Which means you don't have
Option Strict On in VB. I strongly recommend you always have Option
String On (except in specialised cases where late binding is necessary,
eg Office Interop). Compile time errors are a hundred times better than
run time errors.

Of course, this will mean your VB will end up looking like C#:

theRow = CType(DsLogin1.CustLogin.Rows(0), CustLoginRow)

--
Larry Lard
Replies to group please

May 15 '06 #10

P: n/a
Yes, strongly typed data set. so?
(thanks for the answer on the "Crutch methods")
T
"Larry Lard" <la*******@hotmail.com> wrote in message
news:11*********************@u72g2000cwu.googlegro ups.com...

Tina wrote:
In vb we say....

Dim theRow As dsLogin.CustLoginRow
theRow = DsLogin1.CustLogin.Rows(0)


Hmm, a strongly typed dataset, or no?

If I try to say the following in C# it says I can't do an implicit
conversion...

dsLogin.CustLoginRow theRow;
theRow = dsLogin1.CustLogin.Rows[0];

So I had to say......

dsLogin.CustLoginRow theRow;
theRow = (dsLogin.CustLoginRow) dsLogin1.CustLogin.Rows[0];

that's pretty wordy. Is there a better way to say this in C#?


So it's not a strongyly-typed dataset. Which means you don't have
Option Strict On in VB. I strongly recommend you always have Option
String On (except in specialised cases where late binding is necessary,
eg Office Interop). Compile time errors are a hundred times better than
run time errors.

Of course, this will mean your VB will end up looking like C#:

theRow = CType(DsLogin1.CustLogin.Rows(0), CustLoginRow)

--
Larry Lard
Replies to group please

May 15 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.