0

I've got a list of object of this class

public MyClass{
string code;
string other;
string other2;
}

i want to replace all char in code property with a custom char Ex: 'X' ,except last 4 chars, and return the modified list. Possible using linq or not a lot of lines of code?

List<MyClass> classes = new List<MyClass>();
classes = //something that populate the list
classes.Select( e => ???? )
return classes; // returning the modified list
1
  • What would you like to replace? Is there any pattern? Please, be more specific and provide more details. Commented Feb 20, 2015 at 16:04

2 Answers 2

1

use classes.foreach(x => {ur logic here..possibly a method inside MyClass})

Sign up to request clarification or add additional context in comments.

1 Comment

classes.foreach(c => c.code = new string('X', c.code.Length - 4) + c.code.Substring(c.code.length - 4))
0
classes = classes
    .Select(c => {
        c.code = new string('X', c.code.Length - 4) + c.code.Substring(c.code.length - 4);
        return c;
    })
    .ToList();

1 Comment

i need to return a List<MyClass>, in this way i return a string list, can you help me?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.