how to set the get and the set of a var c# code example
Example 1: set in javascript
let mySet = new Set()
mySet.add(1)
mySet.add(5)
mySet.add(5)
mySet.add('some text')
let o = {a: 1, b: 2}
mySet.add(o)
mySet.add({a: 1, b: 2})
mySet.has(1)
mySet.has(3)
mySet.has(5)
mySet.has(Math.sqrt(25))
mySet.has('Some Text'.toLowerCase())
mySet.has(o)
mySet.size
mySet.delete(5)
mySet.has(5)
mySet.size
console.log(mySet)
Example 2: How to set the value to be selected in the dropdownlist in mvc
• Here , Model is a dynamic object and from that modal we are
fetching States property which is of list type.
• Here , employee is an employee object and from that object
we are fetching state property which is of string type.
@foreach (var S in Model.States)
{
if (S.StateName == employee.State)
{
<option value="@S.StateName" selected="selected">@S.StateName</option>
}
else
{
<option value="@S.StateName">@S.StateName</option>
}
}