Concatenating specific properties values of class
-
I have a class public class t1 { public string Name { get; set; } public string rr { get; set; } public string ss { get; set; } public string yy { get; set; } } i am concatenating values of a class like this var yy = string.Join("", typeof(t1).GetProperties().Select(x => x.GetValue(ttt))); i want to remove some of the properties from concatenating how can it be achieved I know that in select i can write x.property name etc.. but how can I do it in one line
-
I have a class public class t1 { public string Name { get; set; } public string rr { get; set; } public string ss { get; set; } public string yy { get; set; } } i am concatenating values of a class like this var yy = string.Join("", typeof(t1).GetProperties().Select(x => x.GetValue(ttt))); i want to remove some of the properties from concatenating how can it be achieved I know that in select i can write x.property name etc.. but how can I do it in one line
You may add some where to your select?
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
-
You may add some where to your select?
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
-
I didn't get you...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
-
I didn't get you...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
I have a need to concat some property values of a class let's say
public class t1
{
public string Name { get; set; }
public string rr { get; set; }
public string ss { get; set; }
public string yy { get; set; }
}easy way is
var yy = string.Join("", typeof(t1).GetProperties().Select(x => x.GetValue(ttt)));
but then it will have all the properties i want a way in which i can specify the properties which i want to exclude from concatenating. one way is i mention all the properties which i want to concat like this
var yy = t1.Name + t1.rr;
but then this is old fashioned and i have a class which has 70+ properties so it is laborious i want a shortcut. Hopr i make myself clear
-
I have a need to concat some property values of a class let's say
public class t1
{
public string Name { get; set; }
public string rr { get; set; }
public string ss { get; set; }
public string yy { get; set; }
}easy way is
var yy = string.Join("", typeof(t1).GetProperties().Select(x => x.GetValue(ttt)));
but then it will have all the properties i want a way in which i can specify the properties which i want to exclude from concatenating. one way is i mention all the properties which i want to concat like this
var yy = t1.Name + t1.rr;
but then this is old fashioned and i have a class which has 70+ properties so it is laborious i want a shortcut. Hopr i make myself clear
So. That what I suggest. Add some where on property name to exclude them... You also can add some custom attribute to the properties you want to access and get only properties that have the specific attribute...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
-
So. That what I suggest. Add some where on property name to exclude them... You also can add some custom attribute to the properties you want to access and get only properties that have the specific attribute...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
-
var oProperties = typeof(t1).GetProperties().Where(oProp => Attribute.IsDefined(oProp, typeof(MyAttribute)));
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)