c# object generic use without casting? -


object s; s = "abc"; int n = ((string)s).length; 

is there way of avoiding having use cast in 3rd line?

edit: "string" , "length" examples , different.

edit: further clarified regarding var , dynamic breaking first line more requirements.

dynamic s = "abc"; int n = s.length; 

Comments