Click here to Skip to main content
15,444,993 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have a function whose return type is multi dimension array . i want to get the values of this function, defined in one class; called from another class without using static. how would i perform the operation.

What I have tried:

i have used property for this but with no expected result.
Updated 3-Feb-21 21:20pm
Richard MacCutchan 4-Feb-21 5:03am    
Use a proper collection class to create and mange the data.
Richard Deeming 4-Feb-21 7:18am     CRLF
REPOST This is the same question you posted yesterday, with less useful information: How to transfer function value through property ?[^]

1 solution

See example here: C# Class get returning two dimensional array - Stack Overflow[^]
But see the warning here: CA1819: Properties should not return arrays (code analysis) - .NET | Microsoft Docs[^]

And here is a simple example (although returning arrays this way is not really recommended either):
var test = new Test();
var arr = test.TestArray();
Debug.Print(arr[0, 0]);
Debug.Print("arr.Length = " + arr.Length);
public class Test
    public string[,] TestArray()
        string[,] testArr = new string[5, 5];
        testArr[0, 0] = "0,0 test";
        return testArr;
Share this answer
Member 12712527 4-Feb-21 3:49am    
possibly no
Member 12712527 4-Feb-21 5:40am     CRLF
sir i have done the same thing and the values are okay if it is called from different function of the same class but value is missing once called from different class . how to solve the problem
Maciej Los 4-Feb-21 6:05am    

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