我想从我的汽车类中的参数中提取一个实例,在我的代码中我有类似的东西:
class Car
{
static Car MakeCustomCarWithColor(string color)
{
return new Car(c => c.Color = color);
}
public Car(Action<ICustomizeCar> customization)
{
//here I want to access the values from customization
// how to convert Action<ICustomizeCar>
ICustomizeCar myCustom = ?????????????????????????????;
// It prints the color passed from Builder class
Console.WriteLine(myCustom.Color);
}
public interface ICustomizeCar
{
string Color { get; set; }
}
}
答案 0 :(得分:1)
在我看来,您的Car类应该实现ICustomizeCar接口,因此您可以将此指针发送到该操作。
<textarea id="source" onkeyup="translate();"></textarea>
<div id="result"></div>
<script type="text/javascript">
function translate() {
var source = document.getElementById('source').value;
... ???
document.getElementById('result').innerHTML = result;
}
</script>