473,395 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

@SomeFunction() ???????


Yello,
Quick Q:
I used a converter to convert vb code to C# (and not very well I might add.)
One of the things it did is an @ symbol to a few of the functions. I know
what it means when you do it to a string, but what about a function?

eg:
_numberOfRecords = @BitConverter.ToInt32(foxArray, 4);

No errors are thrown but I dont understand it.

Thanks in advance for all help on this issue.
Mar 23 '06 #1
5 1115

"TheMadHatter" <Th**********@discussions.microsoft.com> wrote in message
news:74**********************************@microsof t.com...

Yello,
Quick Q:
I used a converter to convert vb code to C# (and not very well I might
add.)
One of the things it did is an @ symbol to a few of the functions. I know
what it means when you do it to a string, but what about a function?

eg:
_numberOfRecords = @BitConverter.ToInt32(foxArray, 4);

No errors are thrown but I dont understand it.

Thanks in advance for all help on this issue.


The @ symbol is used to reference variables that have the same name as a C#
keyword. For example, the following code was pulled from the MSDN library:

class @class
{
public static void @static(bool @bool) {
if (@bool)
System.Console.WriteLine("true");
else
System.Console.WriteLine("false");
}
}
class Class1
{
static void M() {
class.static(true);
}
}
HTH! :)

Mythran

Mar 23 '06 #2
Hi,
you can use the @ symbol to use reserved keywords as variable names /
methods etc. So you could have a variable called string or other things like
that. i.e.

using System;

namespace ConsoleApplication22
{
class Program
{
static void Main(string[] args)
{
string @string = "hello";
Console.WriteLine(@string);
@int();
Console.ReadLine();
}

public static void @int()
{
Console.WriteLine("hello again");
}
}
}

--
http://www.markdawson.org
"TheMadHatter" wrote:

Yello,
Quick Q:
I used a converter to convert vb code to C# (and not very well I might add.)
One of the things it did is an @ symbol to a few of the functions. I know
what it means when you do it to a string, but what about a function?

eg:
_numberOfRecords = @BitConverter.ToInt32(foxArray, 4);

No errors are thrown but I dont understand it.

Thanks in advance for all help on this issue.

Mar 23 '06 #3
In addition to what others have said it's most obvious purpose to use
an assembly developed in another language in which the developer
unwittingly used C# keywords in the public interface. I have not yet
had a need to use it in this manner though.

Brian

TheMadHatter wrote:
Yello,
Quick Q:
I used a converter to convert vb code to C# (and not very well I might add.)
One of the things it did is an @ symbol to a few of the functions. I know
what it means when you do it to a string, but what about a function?

eg:
_numberOfRecords = @BitConverter.ToInt32(foxArray, 4);

No errors are thrown but I dont understand it.

Thanks in advance for all help on this issue.


Mar 24 '06 #4
Mark R. Dawson <Ma*********@discussions.microsoft.com> wrote:
you can use the @ symbol to use reserved keywords as variable names /
methods etc. So you could have a variable called string or other things like
that. i.e.


<snip>

It should be noted, by the way, that this should be avoided wherever
possible. It's really available so that you can use code written in
other languages with different keywords, which may have used a C#
keyword as an identifier. It would be madness to write your own C# code
which deliberately used keywords as identifiers.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 24 '06 #5
I agree with you 100%.
--
http://www.markdawson.org
"Jon Skeet [C# MVP]" wrote:
Mark R. Dawson <Ma*********@discussions.microsoft.com> wrote:
you can use the @ symbol to use reserved keywords as variable names /
methods etc. So you could have a variable called string or other things like
that. i.e.


<snip>

It should be noted, by the way, that this should be avoided wherever
possible. It's really available so that you can use code written in
other languages with different keywords, which may have used a C#
keyword as an identifier. It would be madness to write your own C# code
which deliberately used keywords as identifiers.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Mar 24 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - I have <a href="javascript:somefunction()"what .... ?...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.