Hello,
How do I make a function the "default" function? In VB.NET its the keyword
default, is there a C# equivalent?
Thanks In Advance.
Regards
Simon Jefferies
Tools Programmer, Headfirst Productions
mailto:si****@h eadfirst.co.uk www.headfirst.co.uk www.callofcthulhu.com
- 7 3794
Hello Simon,
Not sure what does this keyword mean in VB .NET... If this is an indication
of the default property (the one that can be referenced without specifying
the property name), then you are limited to argument-overloadable indexers
(which work in a very similar way) in C#. Please also note that this is the
only way to have a property with arguments in C#.
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"Simon Jefferies" <si****@headfir st.co.uk> wrote in message
news:%2******** **********@TK2M SFTNGP12.phx.gb l... Hello,
How do I make a function the "default" function? In VB.NET its the keyword default, is there a C# equivalent?
Thanks In Advance.
Regards Simon Jefferies Tools Programmer, Headfirst Productions mailto:si****@h eadfirst.co.uk www.headfirst.co.uk www.callofcthulhu.com -
> How do I make a function the "default" function? In VB.NET its the keyword default, is there a C# equivalent?
What to hell is a default function? Please explain.
--
cody
Freeware Tools, Games and Humour http://www.deutronium.de.vu || http://www.deutronium.tk
In VB .NET you can set a function etc to be the default. This means that you
don't need to specify the name of function for example:
MyObject.Item(0 )
can be replaced with just:
MyObject(0)
HTH
Regards
Simon Jefferies
Tools Programmer, Headfirst Productions
mailto:si****@h eadfirst.co.uk www.headfirst.co.uk www.callofcthulhu.com
-
"cody" <no************ ****@gmx.net> wrote in message
news:Od******** ******@TK2MSFTN GP11.phx.gbl... How do I make a function the "default" function? In VB.NET its the keyword default, is there a C# equivalent?
What to hell is a default function? Please explain.
-- cody
Freeware Tools, Games and Humour http://www.deutronium.de.vu || http://www.deutronium.tk
> In VB .NET you can set a function etc to be the default. This means that
you don't need to specify the name of function for example:
MyObject.Item(0 )
can be replaced with just:
MyObject(0)
This is no default function, it is an indexer.
in C# you declare an indexer like that:
int this(int index)
{
get { return array[index] ; }
set { array[index] =value; }
}
--
cody
Freeware Tools, Games and Humour http://www.deutronium.de.vu || http://www.deutronium.tk
What you are looking for is called Indexer in C#.
An indexer is similar to a property. As with properties,
you use get and set when defining an indexer. Unlike
properties, you are not obtaining a specific data member;
rather, you are obtaining a value from the object itself.
The format for defining an indexer is:
public dataType this[int index]
{
get
{
// Do whatever you want...
return aValue;
}
set
{
// Do whatever you want
// Generally you should set a value within the
class
// based on the index and the value they assign.
}
}
Check the thread "Default Properties" in this group, for
more info.
And the following link may provide more help: http://www.codeguru.com/Csharp/Cshar...ax/indexers/ar
ticle.php/c5833/
--
Cheers,
Rahul Anand -----Original Message----- In VB .NET you can set a function etc to be the default.
This means that youdon't need to specify the name of function for example:
MyObject.Item( 0)
can be replaced with just:
MyObject(0)
HTH Regards Simon Jefferies Tools Programmer, Headfirst Productions mailto:si****@ headfirst.co.uk www.headfirst.co.uk www.callofcthulhu.com - "cody" <no************ ****@gmx.net> wrote in message news:Od******* *******@TK2MSFT NGP11.phx.gbl.. . How do I make a function the "default" function? In
VB.NET its the keyword default, is there a C# equivalent?
What to hell is a default function? Please explain.
-- cody
Freeware Tools, Games and Humour http://www.deutronium.de.vu || http://www.deutronium.tk
.
Hi Simon,
I think you have got a lot of useful feedback from the community. Does the
community's reply make sense to you?
Do you still have any concern on this issue? Please feel free to post.
Thanks
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Hello,
Thanks for your replies, the information has been helpful.
Regards
Simon Jefferies
Tools Programmer, Headfirst Productions
mailto:si****@h eadfirst.co.uk www.headfirst.co.uk www.callofcthulhu.com
-
""Jeffrey Tan[MSFT]"" <v-*****@online.mi crosoft.com> wrote in message
news:7c******** ******@cpmsftng xa10.phx.gbl... Hi Simon,
I think you have got a lot of useful feedback from the community. Does the community's reply make sense to you?
Do you still have any concern on this issue? Please feel free to post. Thanks
Best regards, Jeffrey Tan Microsoft Online Partner Support Get Secure! - www.microsoft.com/security This posting is provided "as is" with no warranties and confers no rights. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Sean R. Lynch |
last post by:
I've been playing around with Zope's RestrictedPython, and I think I'm
on the way to making the modifications necessary to create a
capabilities-based restricted execution system. The idea is to strip out
any part of RestrictedPython that's not necessary for doing capabilities
and do all security using just capabilities.
The basic idea behind capabilities is that you don't give any piece of
code you don't trust a reference to something...
|
by: Jason Heyes |
last post by:
I want to allow objects of my class to be read from an input stream. I am
having trouble with the implementation. Here are the different approaches I
have tried:
// Version 1.0 - Default constructors
class MyClass
{
Foo foo; // foo and bar require default constructors
Bar bar;
public:
|
by: Dixie |
last post by:
I wish to add some fields to an existing table in code.
I am using the following code from rkc.
CurrentDb.Execute ("ALTER TABLE MyTable ADD MyNewField Text 25")
This works , but I need to also set the Required, Allow Zero Length and
Indexed attributes. I have tried but keep getting a syntax error.
Also, can I set the default value of a field in code?
Has anyone some examples of these.
TIA
|
by: Carlos Lozano |
last post by:
Hi,
What is the right way to create an OCX COM component. The component is
already registerred, but can't create an instance. I am using the reference
to the interop module created.
If I use javascript or vbscript it works.
I will appreciate any help.
I do the following (C#):
|
by: Jeff |
last post by:
Hi -
I understand how to create a directory folder, but how can I programatically
create a _shared_ directory folder and set its permissions?? (I'm using
VB.NET.)
Thanks for your help.
- Jeff
| |
by: Gary Kahrau |
last post by:
I want to create a function and can only get half way to my goal.
dim sStr as string
sStr = Entry(2,"a,b,c,d") ' Sets sStr = "b"
Entry(2,sStr) = "B" ' Sets sStr = "a,B,c,d"
I tried create a public property. However, the Set does not allow
ByRef. How do I work around this?
|
by: Peter Erickson |
last post by:
I am running postgresql 7.4.2 and having problems creating a trigger
function properly. I keep getting the following error:
ERROR: OLD used in query that is not in rule
I have a table called journal_entries with a foreign key to a table
called journals. When a entry is added to journal_entries, I am trying
to get it to update the 'mtime' field of the corresponding entry in the
journals table.
|
by: Motoma |
last post by:
This article is cross posted from my personal blog. You can find the original article, in all its splendor, at http://motomastyle.com/creating-a-mysql-data-abstraction-layer-in-php/.
Introduction:
The goal of this tutorial is to design a Data Abstraction Layer (DAL) in PHP, that will allow us to ignore the intricacies of MySQL and focus our attention on our Application Layer and Business Logic. Hopefully, by the end of this guide, you will...
|
by: Bartholomew Simpson |
last post by:
I am writing some C++ wrappers around some legacy C ones - more
specifically, I am providing ctors, dtors and assignment operators for
the C structs.
I have a ton of existing C code that uses these structs. A typical usage
case will be as ff (note the code below is Pseudocode and WILL NOT compile)
//example structs (I have left out the ctors/dtors etc for brevity sake)
struct MyStructA
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |