Answers for "Property or indexer cannot be assigned to -- it is read only "tests""

C#
0

Property or indexer cannot be assigned to -- it is read only "tests"

// If this is for tests:
// You could just mock this (I use the Moq library)
Mock<SomeObj> SomeObjMock = new Mock<SomeObj>();

SomeObjMock.Setup(
	s =>
	s.MatchedCount
).Returns(matched_modified_count);


//If not for tests:
// If its from some outside library you could change via mutation,
// BUT this is wrong since the writer on purpose made this readonly
//If its you own class and you need it than just set a setter for field
Posted by: Guest on March-27-2022

Code answers related to "Property or indexer cannot be assigned to -- it is read only "tests""

C# Answers by Framework

Browse Popular Code Answers by Language