Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

Resetting Properties Of an Object Using LINQ

$
0
0

Suppose I have a method called ShowScores and all this method does is display each gamer's score. Basically there is a GamersRecords class which contains a  list of records. Each record has GamersName and Score properties. I want to set to zero all the Scores that are below the Qualifying score of 50 using LINQ. 

Below is what I've tried but I was not successful.

public class GamersRecords
{
public GamersRecords(List<Record> records)
{
this.Records = records;
}
public List<Record> Records{get;set;}
}

public class SomeClass
{
public ShowScores(GamersRecords records)
{
var newRecords = records.selectMany(g=>g.Score < 50).Score=0; foreach(newRecord in newRecords) { Console.WriteLine("Contestant's Name " + newRecord.GamersName + "Final Score" + newRecord.Score); }
}
}


Viewing all articles
Browse latest Browse all 1698

Trending Articles



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