Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Class Return Value

Status
Not open for further replies.

Neily

Programmer
Jul 27, 2000
342
GB
I want to return a value for my class without needing to call a method in that class.

For example:

class MyClass1
{
String myString = "A String";
}

MyClass1.myString would give me: A String wherever used.

What I need is a List<String> that will return as a CSV String when used:

class MyClass1
{
MyClass2 myClass;
}

MyClass1.myClass.Add("Test1");
MyClass1.myClass.Add("Test2");

In this example I want MyClass1.myClass to return: Test1, Test2

So I need to be able to create a class that can be used similarly to a String class but has the functionality of List<String>.

Neil
 
I want to return a value for my class without needing to call a method in that class.
why not use a class the way it was intended? a class has members the members have behavior.
Code:
var c = new Class();
var p = c.Property;
var m = c.Method();
var a = c.MethodWith("a string argument");
[code]
what value is gained by treating a class like a member?

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
I'm using the SimpleSavant project to put and get to SimpleDB. Savant determines the type of each member of my class but (for this project at least) I need savant to combine the entries in a list and put them into SimpleDB as a CSV string.

The data in question are strings that are tags for my other data. I like the ability to use the .Add() method of List<String> to add tags as necessary. It is looking like I can't do what I want or come up with a clever alternative.

Neil
 
SS sounds like a document database. if that's the case you would store something like this
Code:
class MyClass
{
   public int i {get;set;}
   public string[] strings {get;set;}
}
or you would treat each instance as a row.
Code:
class MyClass
{
   public int i {get;set;}
   public string s {get;set;}
}
and query for a set of objects.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top