Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Write the code in more releadable old ways.

$
0
0

Can someone help me write the code in old ways, like in C# 2005. 

For example there is a class

publicclassProduct{publicintId{get;set;}publicstringName{get;set;}publicstringCategory{get;set;}publicdecimalPrice{get;set;}}

now I am initiating this class in to an array object, how i can rewrite it in longer version.  For me that is more readable.

Product[] products =newProduct[]{newProduct{Id=1,Name="Tomato Soup",Category="Groceries",Price=1},newProduct{Id=2,Name="Yo-yo",Category="Toys",Price=3.75M},newProduct{Id=3,Name="Hammer",Category="Hardware",Price=16.99M}};

2) Also if instead of writing the above code I want to have these objects in List<product> how would I do that.


i am a novice and a student


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>