Click here to Skip to main content
15,883,896 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I first tried to use a public property, array, and call the array from the calling app. Can't find a way to do that. What is the simplest method to achieve passing a multiple of values that are generated in the dll? I know I can generated a string in the dll with the variables separated by comma, then create an array from this in the calling program. Is there any more direct method?

What I have tried:

I have tried to use an array property in the dll without success.
Posted
Updated 21-Sep-18 20:02pm

There's a variety of ways to do this, but you left out all the important details in your description so it's impossible to say what's more appropriate.

You can return an array, an ArrayList, a List, a List<t>, a structure designed to carry a bunch of different types at once, or a class instance that holds the values in properties.
You can return values to variable that call the method and pass in variables by reference.

There's lots of options, but since we can't see you're code (you didn't post any snippets), we can't tell you what you're doing wrong.
 
Share this answer
 
The fact that it's a DLL is irrelevant - the procedure is the same regardless of where the class containing the data is.
Stop and think about the data you want to pass, and how you would handle it if it was in the same assembly. Work out how you would do it there, and it's the same solution for a class in a DLL - all you need to do is add the reference to the DLL to your project, and a using statement to the source file to access it.
Then it's exactly the same: static data is accessed via the class name, instance data via the instance of the class you created:
public class InTheDLL
    {
    public static string[] StaticArrayOfStrings { get { ... } set { } }
    public List<MyClass> Items { get{ ...} set { } }
    }


string[] strings = InTheDLL.StaticArrayOfStrings;
InTheDLL instance = new InTheDLL();
List<MyClass> collection = instance.Items;
You can return anything, including multiple properties, tuples, whatever your data requires.
 
Share this answer
 
Comments
BobbyStrain 22-Sep-18 17:48pm    
Griff,
I was so focused on proper syntax that I overlooked that the method in the library requires one parameter. Once I corrected that, all is well. Thanks for your help. With this bit, I believe I have finished my project, for now.
OriginalGriff 23-Sep-18 2:59am    
Good for you! :thumbsup:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900