473,503 Members | 3,171 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

get names of parameters

Hi All,

int a;
string b;
float c;

Test(a,b,c);

How do i get the the Test function to print a b c

public static Test(params object[] inputParams)
{

foreach (object inputParam in inputParams)
{
print(something);
}

}

Mar 28 '07 #1
4 1619
You can't. Reflection, at best, will give you the fact that the Test
method has the inputParams parameter.

The only way you can do this is if you hook into the runtime, or if you
pass the names of the parameters and the values explicitly.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"parez" <ps*****@gmail.comwrote in message
news:11*********************@y66g2000hsf.googlegro ups.com...
Hi All,

int a;
string b;
float c;

Test(a,b,c);

How do i get the the Test function to print a b c

public static Test(params object[] inputParams)
{

foreach (object inputParam in inputParams)
{
print(something);
}

}

Mar 28 '07 #2
parez <ps*****@gmail.comwrote:
int a;
string b;
float c;

Test(a,b,c);

How do i get the the Test function to print a b c
You can't. The called function has no clue where its values came from.
They may not even be variables.

--
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 28 '07 #3
On Mar 28, 2:36 pm, Jon Skeet [C# MVP] <s...@pobox.comwrote:
parez <psaw...@gmail.comwrote:
int a;
string b;
float c;
Test(a,b,c);
How do i get the the Test function to print a b c

You can't. The called function has no clue where its values came from.
They may not even be variables.

--
Jon Skeet - <s...@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
Thanks all for the reply!
I think i will pass the names to the function.

Mar 28 '07 #4
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in message
news:eM*************@TK2MSFTNGP05.phx.gbl...
You can't. Reflection, at best, will give you the fact that the Test method has the
inputParams parameter.

The only way you can do this is if you hook into the runtime, or if you pass the names
of the parameters and the values explicitly.
Nicholas ,
Even the runtime has no clue about where these arguments came from, they are passed on the
stack or in a register and only the JIT has an idea where they came from at compile time.
Even using a low-level debugger with the symbol files (PDB) it's quite hard to find these
names back.

Willy.
Mar 28 '07 #5

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

Similar topics

2
1791
by: Amir Michail | last post by:
Hi, I was wondering if there is a tool that will perform some heuristic checking of actual and formal parameters to warn about likely errors. Such a tool could check that formal and actual...
10
2838
by: Andres Eduardo Hernando | last post by:
Hi, I'm not entirely sure this is the right group to ask this question, but I saw a similar one above, and the group's charter is not clear enough about it, so, here I go: ;) What is the...
1
1224
by: Andrew Poulos | last post by:
If I'm writing a sizeable chunk of javascript (1000s of lines) and it includes lots of custom functions, global variables, prototypes etc is there an agreed, customary, conventional, or best...
2
23873
by: Joe | last post by:
Hi All, I am new to using the Access DB and I need some help if someone is able to give it to me. What I want to do is get the names of the columns of certain tables. Not the data in the table...
4
2732
by: don | last post by:
I have two existing interfaces having methods with same names. Now I have to implement both intrfaces in one class. Is there any way I could implement methods with same names in both interfaces...
1
2099
by: tsorgi | last post by:
I'm writing a data conversion application to support a system migration. The code is reading formatted text files and loading them into MS SQL 2005 database tables. I wanted to call the existing...
3
2025
by: SRoubtsov | last post by:
Dear all, Do you know whether ANSI C (or some other dialects) support the following: * a variable name coincides with a type name, * a structure/union field name coincides with a type name in...
1
1715
by: ajax.sam | last post by:
hi all, i got 2 questions! i want to do these: 1. select @col1 from some_table where <some_conditions>; I can pass parameters by using Parameters.Add for <some_conditionsbut not for the @col1....
2
2096
by: Infog | last post by:
I have written a chunk of code that automatically writes a SQL string, using parameters. The parameters themselves are easy, but getting the column names has been a problem. Is possible to get...
0
7188
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
7063
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...
0
7313
jinu1996
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...
1
6970
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
5558
agi2029
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,...
1
4987
isladogs
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...
0
3156
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...
0
1489
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.