Hi,
I am a newbie in c# development, with Delphi/Pascal background. I am missing
much the ability to create local functions, what are embedded into an other
function. Let me give an example:
private int x ()
{
internal bool z (string s)
{
// do some manipulation here
}
bool a = z("abc");
bool b = z("xyz");
}
Here the z is visible only in the code of x. And, what is important , it can
see all the local functions of x. This means, that you don't have to pass all
the gadgets in the parameter list.
Is there any reason, why is it not implemented in c#?
Thanks:
Peter 3 4386
Peter,
I can't speak for the designers of the language, but IMO, I think that
it doesn't offer much benefit compared to how difficult it would be to
implement (would it be a .NET or a C# feature, implemented with "compliler
trickery")? All in all, something very similar can be implemented with the
languages as they are today.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Peter Baranyi" <Pe**********@discussions.microsoft.com> wrote in message
news:09**********************************@microsof t.com... Hi,
I am a newbie in c# development, with Delphi/Pascal background. I am missing much the ability to create local functions, what are embedded into an other function. Let me give an example:
private int x () { internal bool z (string s) { // do some manipulation here } bool a = z("abc"); bool b = z("xyz"); }
Here the z is visible only in the code of x. And, what is important , it can see all the local functions of x. This means, that you don't have to pass all the gadgets in the parameter list. Is there any reason, why is it not implemented in c#? Thanks:
Peter
"Peter Baranyi" <Pe**********@discussions.microsoft.com> writes: Hi,
I am a newbie in c# development, with Delphi/Pascal background. I am missing much the ability to create local functions, what are embedded into an other function. Let me give an example:
private int x () { internal bool z (string s) { // do some manipulation here } bool a = z("abc"); bool b = z("xyz"); }
Here the z is visible only in the code of x. And, what is important , it can see all the local functions of x. This means, that you don't have to pass all the gadgets in the parameter list.
If you use C# 2.0 this is possible using (not tested):
public class MyClass{
delegate int myDelegate(int i);
private int x ()
{
int testInt = 5;
myDelegate del = myDelegate(int i)
{
testInt = i++;
};
int setAndReturnIncrease = del(10);
}
}
/rw
Rico Wind <us****@rico-wind.dk> writes: "Peter Baranyi" <Pe**********@discussions.microsoft.com> writes:
Hi,
I am a newbie in c# development, with Delphi/Pascal background. I am missing much the ability to create local functions, what are embedded into an other function. Let me give an example:
private int x () { internal bool z (string s) { // do some manipulation here } bool a = z("abc"); bool b = z("xyz"); }
Here the z is visible only in the code of x. And, what is important , it can see all the local functions of x. This means, that you don't have to pass all the gadgets in the parameter list. If you use C# 2.0 this is possible using (not tested):
public class MyClass{ delegate int myDelegate(int i); private int x () { int testInt = 5; myDelegate del = myDelegate(int i) { testInt = i++;
There should of course be and
return testInt;
here
(even though it dos not make much sense to return a variable that you
have access to:-), but you probably got the idea)
/rw }; int setAndReturnIncrease = del(10); }
}
/rw This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Wolfgang |
last post by:
I have a problem with linking my CPP Code under a irix6 machine (sgi,
UNIX). In my CPP code I use some Functions which are written in
Python. So its a kind of CPP wrapper for my Python functions In...
|
by: jini us |
last post by:
Hi,
I am starting a new project where I intend to use
embedded database server in my win32 application.
I intend to use VC++ microsoft studio 6.0 as my
development environment.
The...
|
by: Jean-David Beyer |
last post by:
I have some programs running on Red Hat Linux 7.3 working with IBM DB2
V6.1 (with all the FixPacks) on my old machine.
I have just installed IBM DB2 V8.1 on this (new) machine running Red Hat...
|
by: Mark Yudkin |
last post by:
The documentation is unclear (at least to me) on the permissibility of
accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003,
with separate transactions scope, from separate...
|
by: David Mathog |
last post by:
Every so often one of my fgets() based programs encounters
an input file containing embedded nulls. fgets is happy to
read these but the embedded nulls subsequently cause problems
elsewhere in...
|
by: Marina |
last post by:
Hi,
I am trying to find the minimum security settings to allow a windows control
embedded in IE have full trust.
If I give the entire Intranet zone full trust, this works. However, this is...
|
by: VictorReinhart |
last post by:
Hi,
I am intersted in trying to reduce the cost of C# development, by
reducing the number of lines of code. In my opinion, as a business
developer, the biggest opportunity to reduce the number of...
|
by: wardm |
last post by:
I have created a Dict object in a C++ App that calls (embedded) Python
functions.
The Dict is to be used to pass variable data between the C++ App and the
python functions.
However I cannot get...
|
by: iwl |
last post by:
Hello,
I would like to add Variables to my embedded python which represents
variables from my
C++-Programm.
I found C-Api-funcs for adding my C-Funcs to python but none to add
variables.
I...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |