I am trying to write a webmethod which would look a bit like this:
-------------------------------------------------------------------------------------------------------
private string ConnectionString
{
get { return
ConfigurationManager.ConnectionStrings["DBConn"].ConnectionString; }
}
public string[] GetCompletionList_LN(String prefixText)
{
using (SqlConnection conn = new SqlConnection(connectionString))
{
SqlCommand command = new
SqlCommand("sp_DTDS_GetEmployeesByLastName", conn);
SqlParameter param1 = new SqlParameter("@Name", SqlDbType.VarChar);
param1.Value = prefixText;
command.Parameters.Add(param1);
SqlParameter param1 = new SqlParameter("@Counter",
SqlDbType.VarChar);
param2.Size = 3;
param2.Direction = ParameterDirection.Output;
command.Parameters.Add(param2);
conn.Open();
SqlDataReader dtr;
dtr = command.ExecuteReader();
List<String> items = new List<String>();
try
{
while (dtr.Read())
{
items.Add(dtr(0).ToString);
}
}
finally
{
conn.Close();
}
Return items.ToArray();
}
}
-------------------------------------------------------------------------------------------------------
I had
SqlParameter param1 = New SqlParameter("@Name",
SqlDbType.VarChar);
instead of
SqlParameter param1 = new SqlParameter("@Name",
SqlDbType.VarChar);
with "New" instead of "new"
so the compiler complained about
; expected
(?????)
What was the keyword "New" supposed to be, in the compiler's mind ? A
tulip ? Of course New is new !!! I have lost three hours hunting this
down ! This, or course, triggered other stupid error messages
downstream, like, for instance,
conn.Close();
was saying
Invalid token '(' in class, struct, or interface member
declaration
Huh ?
Anyhoo. I still have one problem - the line
Return items.ToArray();
says
; expected
and also typing "items" + dot does not trigger any type of
autocomplete.
Is there smething wrong with
List<String> items = new List<String>();
???
Please, what am I doing wrong here ? This makes me pull my hair out,
and I don't have much left.
I am a VBnet programmer, and this case-sensitivity in C# is the most
stupid thing I've met.
Thank you
Alex.
Peter Bromberg [C# MVP] - 20 Mar 2008 21:02 GMT
Well! If you had started with C++, Javascript or the *nix filesystem instead
of Visual Basic, your frustration level might be a bit lower. All of them are
case-sensitive.
I agree that sometimes compiler error messages can be less than clear. But
case - sensitivity? Get over it!
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short Urls & more: http://ittyurl.net
> I am trying to write a webmethod which would look a bit like this:
>
[quoted text clipped - 84 lines]
> Thank you
> Alex.
Peter Duniho - 20 Mar 2008 21:03 GMT
> [...]
> Anyhoo. I still have one problem - the line
[quoted text clipped - 8 lines]
>
> Please, what am I doing wrong here ?
I would have thought that your previous error would have made you more
_sensitive_ to C#'s particular requirements.
> This makes me pull my hair out,
> and I don't have much left.
> I am a VBnet programmer, and this case-sensitivity in C# is the most
> stupid thing I've met.
Honestly, don't expect to get a lot of help if you insist on telling
people who really enjoy and love C# that the language is "the most stupid
thing you've met".
The fact is, lots of computer languages are case-sensitive, and all of the
most widely-used ones are. Saying that being case-sensitive is "stupid"
is, well...stupid. Just because you are used to using a language that is
not case-sensitive is no reason to go ballistic when you start using one
that is.
Pete
Paul E Collins - 20 Mar 2008 22:50 GMT
> I am a VBnet programmer, and this case-sensitivity in C# is the most
> stupid thing I've met.
Then use VB.NET.
Eq.
Lasse Vågsæther Karlsen - 22 Mar 2008 10:52 GMT
<snip case sensitivity complaint>
> Anyhoo. I still have one problem - the line
> Return items.ToArray();
> says
> ; expected
Return is also written as a lower-case keyword, in fact, all the C#
keywords are lower-case (nagging feeling here that there is one that
isn't, but I can't come up with anything).
> and also typing "items" + dot does not trigger any type of
> autocomplete.
I assume this is in that line, in other words, you're writing:
Return items.
this will cause problems, because the compiler doesn't understand that
you're writing an expression where "items" is a valid word.
> I am a VBnet programmer, and this case-sensitivity in C# is the most
> stupid thing I've met.
Well, it is what it is, so you better get used to it, or continue using
VB.NET. I don't think there is much you can't do in VB that you can do
in C#, so I think you could easily switch back.

Signature
Lasse Vågsæther Karlsen
mailto:lasse@vkarlsen.no
http://presentationmode.blogspot.com/
PGP KeyID: 0xBCDEA2E3
Tom - 22 Mar 2008 23:38 GMT
><snip case sensitivity complaint>
>
[quoted text clipped - 6 lines]
>keywords are lower-case (nagging feeling here that there is one that
>isn't, but I can't come up with anything).
In C#: string = String
^ There's your one.
And about all the case insensitivity you are going to find.
>> and also typing "items" + dot does not trigger any type of
>> autocomplete.
At the first indication of intellisense not working ... fix it.
Sometimes a missing reference causes the problem.
To go beyond a preceding error prevents intellisense helping you the
rest of the way.
At the least ... comment out the offending block and come back to it
later.
Often the IDE flags errors when everything preceding is correct. It's
almost like continuous compilation. I find this feature amazingly
useful.
Go back and type in a command with "New" in a zero compilation error
program. When I try this ... the first word following "New" is
underlined in red. << This is your flagged error!
You are made aware of the above error immediately. Because you were
unaware of the meaning of the flagging and charged ahead ... it cost
you hours of frustration.
------------------------
Surely Radu, can't you can come up with some useful scenarios where
case sensitivity is a plus? I use it all the time and would whine
louder than you are if it was not a feature. Camel hump notation is
one example. Plus you can often illustrate hierarchy cleverly when
Capitalization is used a little outside conventional practice. So it
allows you to have "STYLE" beyond the limitations of VB. < Think about
that a bit ... eh?
And as I often tell my g/f when she challenges my many flaws ...
"Get over it ... cause it ain't changing." hahaha
Cheers.
Lasse Vågsæther Karlsen - 22 Mar 2008 23:39 GMT
>> <snip case sensitivity complaint>
>>
[quoted text clipped - 9 lines]
> ^ There's your one.
> And about all the case insensitivity you are going to find.
No, that's not what I meant. string is the C# keyword for the BCL type
String and I know well the distinction. The nagging feeling is gone,
however, and could just be the effects of my lunch... who knows.

Signature
Lasse Vågsæther Karlsen
mailto:lasse@vkarlsen.no
http://presentationmode.blogspot.com/
PGP KeyID: 0xBCDEA2E3
Jon Skeet [C# MVP] - 22 Mar 2008 23:58 GMT
> > In C#: string = String
> > ^ There's your one.
[quoted text clipped - 3 lines]
> String and I know well the distinction. The nagging feeling is gone,
> however, and could just be the effects of my lunch... who knows.
The spec doesn't indicate any keywords beginning with a capital, as far
as I can see.
I don't suppose you're thinking of the preference for using "L" instead
of "l" as a suffix for longs, are you? (On the grounds that "l" can
look like "1", whereas "d", "m" and "f" don't have that issue.)
I reckon your lunch is the culprit here. What was it, anyway? :)

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Lasse Vågsæther Karlsen - 23 Mar 2008 01:15 GMT
>>> In C#: string = String
>>> ^ There's your one.
[quoted text clipped - 9 lines]
> of "l" as a suffix for longs, are you? (On the grounds that "l" can
> look like "1", whereas "d", "m" and "f" don't have that issue.)
No, definitely not that.
> I reckon your lunch is the culprit here. What was it, anyway? :)
Something with eggs... you know how that can go.

Signature
Lasse Vågsæther Karlsen
mailto:lasse@vkarlsen.no
http://presentationmode.blogspot.com/
PGP KeyID: 0xBCDEA2E3
Jon Skeet [C# MVP] - 22 Mar 2008 23:56 GMT
> >Return is also written as a lower-case keyword, in fact, all the C#
> >keywords are lower-case (nagging feeling here that there is one that
> >isn't, but I can't come up with anything).
>
> In C#: string = String
> ^ There's your one.
No, only "string" is a keyword. String isn't.
> And about all the case insensitivity you are going to find.
That's not case insensitivity. It's aliasing "string" for the type
"System.String".
In particular, it's very easy to come up with a program where using
"String" instead of "string" fails to compile:
class Test
{
static void Main(string[] args) {}
}
Just those four lines, on their own - they compile to a trivial
application. Change "string" to "String" and they won't, because
there's no "String" type and no using directives to guide the compiler
to System.String.
<snip>

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Michael A. Covington - 23 Mar 2008 00:07 GMT
>>Return is also written as a lower-case keyword, in fact, all the C#
>>keywords are lower-case (nagging feeling here that there is one that
[quoted text clipped - 3 lines]
> ^ There's your one.
> And about all the case insensitivity you are going to find.
Technically, "string" is a C# keyword and "String" is a CLR type name; they
happen to denote the same thing, but this is not a matter of case
insensitivity, it's two synonymous words that happen to differ only in case.
Martin Bonner - 23 Mar 2008 09:33 GMT
On Mar 22, 11:07 pm, "Michael A. Covington"
<l...@ai.uga.edu.for.address> wrote:
> >>Return is also written as a lower-case keyword, in fact, all the C#
> >>keywords are lower-case (nagging feeling here that there is one that
[quoted text clipped - 7 lines]
> happen to denote the same thing, but this is not a matter of case
> insensitivity, it's two synonymous words that happen to differ only in case.
Time to climb on my hobby horse here: Technically, String is /not/ a
CLR type name. However System.String is, and because most C# files
start with "using System;" you can refer to System.String as just
String.
RobinS - 22 Mar 2008 19:04 GMT
Don't feel too bad. When I first started C#, I spent 10 minutes one day
trying to figure out why this didn't work:
If (a == b)
{
}
(If should not be capitalized).
RobinS.
------------------------
>I am trying to write a webmethod which would look a bit like this:
>
[quoted text clipped - 84 lines]
> Thank you
> Alex.
Ben Voigt [C++ MVP] - 24 Mar 2008 15:13 GMT
> Don't feel too bad. When I first started C#, I spent 10 minutes one
> day trying to figure out why this didn't work:
[quoted text clipped - 4 lines]
>
> (If should not be capitalized).
In other news, notepad is better at editing source code than Word.
> RobinS.
> ------------------------
[quoted text clipped - 86 lines]
>> Thank you
>> Alex.
Chris Shepherd - 24 Mar 2008 18:51 GMT
>> If (a == b)
>> {
[quoted text clipped - 3 lines]
>
> In other news, notepad is better at editing source code than Word.
Yes, and NEVER let Outlook auto-capitalize for your if you're mailing code
samples. Best to use something akin to pastebin or send files in those
circumstances.
Chris.
RobinS - 27 Mar 2008 07:14 GMT
>> Don't feel too bad. When I first started C#, I spent 10 minutes one
>> day trying to figure out why this didn't work:
[quoted text clipped - 6 lines]
>
> In other news, notepad is better at editing source code than Word.
What about writing code on a piece of paper, scanning it in, and hoping my
OCR program works? ;-)