If something like the following is written anywhere in a class,
public bool? IsHelthy(int age, double weight, string type)
{
switch (type)
{
case "cat":
return weight > age * 5;
case "dog":
return weight > age * 10;
default:
return null;
}
}
the cursor is inside the IsHelthy method, and the Create Class From Method command is called up, and a class/file name is provided properly, e.g. 'Pet', the following class will be created:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CS_Class
{
public class Pet
{
public bool? IsHelthy()
{
switch (type)
{
case "cat":
return weight > age * 5;
case "dog":
return weight > age * 10;
default:
return null;
}
}
private string type;
private double weight;
private int age;
}
}
Enjoy!
No comments:
Post a Comment