how to return two string values in a C# Class library

how to return two string values in a C# Class library

Page 1 of 1

6 Replies - 4060 Views - Last Post: 18 March 2009 - 09:16 AM Rate Topic: -----

#1 bharathi305  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 18-March 09

how to return two string values in a C# Class library

Post icon  Posted 18 March 2009 - 07:36 AM

how to return two string values in a C# Class library
Is This A Good Question/Topic? 0
  • +

Replies To: how to return two string values in a C# Class library

#2 bharathi305  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 18-March 09

Re: how to return two string values in a C# Class library

Posted 18 March 2009 - 07:38 AM

how to return two string values in a C# Class library
Was This Post Helpful? 0
  • +
  • -

#3 Ryan Marfone  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 87
  • Joined: 23-February 09

Re: how to return two string values in a C# Class library

Posted 18 March 2009 - 07:43 AM

Post what you have tried and you'll get a better response.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 6432
  • View blog
  • Posts: 23,421
  • Joined: 12-June 08

Re: how to return two string values in a C# Class library

Posted 18 March 2009 - 08:00 AM

with a routine's parameters. you can even put 'ref' in front of the parameter to make sure everyone notices it's by reference.. though I don't think that is necessary since c# should pass everything by ref.
Was This Post Helpful? 0
  • +
  • -

#5 ragingben  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 164
  • View blog
  • Posts: 612
  • Joined: 07-October 08

Re: how to return two string values in a C# Class library

Posted 18 March 2009 - 08:15 AM

I think that what you are looking for is to hve a method for your class that returns two strings? If this is so, it is not possible (as far as I know) in the way you are asking for. You could do either of the following

1 - Return an array of some description containing both strings, or...
2 - Return an custom class containing both your string fields. This I would recommend - if your common object you want to return has 2 fields (strings in this case) shouldn't you have a class for it?

This post has been edited by ragingben: 18 March 2009 - 08:16 AM

Was This Post Helpful? 0
  • +
  • -

#6 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1619
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: how to return two string values in a C# Class library

Posted 18 March 2009 - 08:57 AM

Topics merged, please don't create duplicate topics :)
Was This Post Helpful? 0
  • +
  • -

#7 StCroixSkipper  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 10
  • View blog
  • Posts: 121
  • Joined: 23-December 08

Re: how to return two string values in a C# Class library

Posted 18 March 2009 - 09:16 AM

List<string> Return2Strings()
{
	string one = "string one";
	string two = "string two";
	List<string> stringList = new List<string>();
	stringList.Add(one);
	stringList.Add(two);
	return stringList;


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1