Answers for "get set"

5

java get set

class Employ
{
  public String name;						//name of the employ
  
  public String getName()					//Get the name
  {
    return name;
  }
  
  public String setName(String newName)		//Set the name
  {
    this.name = newName;
  }
}
Posted by: Guest on January-08-2021
2

c# get set

public class Employ
{
    public string Name { get; set; }
}
Posted by: Guest on January-08-2021
1

set get javascript

var person = {
  language : "en",
  get lang() { return this.language; },
  set lang(lang) { this.language = lang; }
};
document.getElementById("demo").innerHTML = person.lang;
person.lang = "es";
Posted by: Guest on April-05-2021
1

get set

class Thing {
  private int secret; // This is a field.

  public int Secret { // This is a property.
    get {
      Debug.Print("Somebody is accessing the secret!");
      return secret;
    }

    set {
      Debug.Print("Somebody is writing to the secret!");
      secret = value; // Note the use of the implicit variable "value" here.
    }
  }
}
Posted by: Guest on May-17-2021
4

c# using get set methods

using System;

public class SaleItem
{
   public string Name 
   { get; set; }

   public decimal Price
   { get; set; }
}

class Program
{
   static void Main(string[] args)
   {
      var item = new SaleItem{ Name = "Shoes", Price = 19.95m };
      Console.WriteLine($"{item.Name}: sells for {item.Price:C2}");
   }
}
// The example displays output like the following:
//       Shoes: sells for $19.95
Posted by: Guest on March-31-2020

Browse Popular Code Answers by Language