Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Can I in C# define a method that accepts an object array of a specific size, and for extra "fun" name each index in the array so that when coding the calling method, when I start to type this method the XML tool tip pop up will show what each index is suppose to represent?

The reason I need this is because I am creating a generic wrapper function that dynamically invokes a method in an assembly loaded at run time, and I want a nice way to invoke and pass in parameters.

I understand the pros and cons, but this would really help to cut down similar code in multiple places, by A LOT.

Thanks in advance.

EDIT

To avoid confusion:

Everything works as is, but currently I have the parameters like (string param1, string param2) and then I have to convert that manually into an array, but I want to do something like (object[2] params) but have the XML comments show what each index should represent.

share|improve this question
1  
Aren't those just called function parameters? An array of objects, of a specific size, and each one has a name? –  Mike Christensen Aug 31 '12 at 15:56
 
Can you give me an example? –  Landin Martens Aug 31 '12 at 16:00
 
Even if Visual Studio could connect the dynamic call to the input parameters, how could it know which assembly you are going to load in the future? I think that you need using System.Tardis; at the top of the file... –  Guffa Aug 31 '12 at 16:01
 
The method void foo(int x, int y, int z) takes a 3 objects (ints), and they have names (x, y, and z). –  Mike Christensen Aug 31 '12 at 16:03
 
Everything works as is, but currently I have the parameters like (string param1, string param2) and then I have to convert that manually into an array, but I want to do something like (object[2] params) but have the XML comments show what each index should represent. Edited main post. –  Landin Martens Aug 31 '12 at 16:05
add comment

1 Answer

up vote 0 down vote accepted

Well by the comments on this question and my own research it seems this is not possible. I formatted the XML comments though in a way that makes it apparent to who ever is calling this method though what the parameters should be and does not make the XML comments two large in size. It does not really solve the size issue but if should be clear enough to the user what is going on. Maybe this will help someone else in the future.

XML formatting Comments below so people can copy and paste if they want to:

/// <summary>
/// Summary of the method, which is seperated nicely from below in tool tip
/// </summary>
/// <param name="parameters">
/// (
/// <c>String </c><param name="paramOne" />, 
/// <c>Int </c><param name="paramTwo" /> 
/// )
/// </param>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.