Solved

Returning collection in C#

Posted on 2014-03-19
5
172 Views
Last Modified: 2014-04-16
Hi guys,

what is the equivalent method of the following in C#

Public Function MyFun( ByVal strSqlQuery as string) as collection

Dim abc as Collection

please help

regards,
0
Comment
Question by:shah36
5 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39939838
sounds like a homework question, so I will guide to the "man pages" first:
http://msdn.microsoft.com/en-us/library/ybcx56wz.aspx

you will see some examples of C# code, which has functions that return some collection-type stuff.
0
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 39939843
Hi shah36;

There is no equivalent type in C# as a Collection but you can use the Visual Basic type by doing the following. Add a Reference to the dll Microsoft.VisualBasic.dll and then add the using statement at the top of the code file, using Microsoft.VisualBasic;. The the code gets translated as follows:
Collection abc = new Collection();

public Collection MyFun( string strSqlQuery )
{

}

Open in new window

0
 

Author Closing Comment

by:shah36
ID: 39939852
Oh thanks a lot. Yes it works. Great stuff

regards
0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 39939856
Not a problem, glad to help.
0
 
LVL 7

Expert Comment

by:niralshah
ID: 40003733
It is
public Collection MyFun( string strSqlQuery)  
{
     Collection abc = new Collection();
     return abc;
}
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

948 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now