我得到了一个特定对象的数组.让我们说对象车.在我的代码中的某些时候,我需要从这个数组中删除所有不符合我所述要求的Car-object.这会在数组中保留空值.
public class Car{
public string type { get; set; }
public Car(string ntype){
this.type = ntype;
}
}
Car[] cars = new Car[]{ new Car("Mercedes"), new Car("BMW"), new Car("Opel");
//This should function remove all cars from the array where type is BMW.
cars = removeAllBMWs(cars);
//Now Cars has become this.
Cars[0] -> Car.type = Mercedes
Cars[1] -> null
Cars[2] -> Car.type = Opel
//I want it to become this.
Cars[0] -> Car.type = Mercedes
Cars[1] -> Car.type = Opel …Run Code Online (Sandbox Code Playgroud) 所以我有一个类的对象列表.在这个列表中我想得到对象在哪里Table.name == "value"
Class Table{
public string name;
private string primarykey;
private string[] columnNames;
//some methods and functions
}
Run Code Online (Sandbox Code Playgroud)
我的问题是有一个有效的方法从linq获取此列表中的指定对象,或者我只是通过基本的搜索算法循环这个.
使用基本搜索算法我的意思是:
foreach(Table t in tables)
{
if(t.name == "value")
return t;
}
Run Code Online (Sandbox Code Playgroud)
那么有没有一种更有效的方法来实现这一点,例如linq?
当它尝试将公式插入单元格时,我得到了运行时1004错误
Range("B64").Value = "=INDEX(AK7:AK123;G74;1)"
//I also tried
Range("B64").Formula = "=INDEX(AK7:AK123;G74;1)"
//And
Range("B64").FormulaR1C1 = "=INDEX(AK7:AK123;G74;1)"
Run Code Online (Sandbox Code Playgroud)
但是这给出了错误.如果我尝试插入一个数字或常规字符串,就像"test"它确实有效,但就像这样,它不会.我是VBA的新手,我想知道为什么这会产生问题,因为它永远不会用于以前的语言.
我还没有在这里找到这个问题,我已经对此进行了一些快速的谷歌研究,但我无法找到这个问题的明确或好的答案.
是否可以在输入字段中注入一段php代码.这实际上是有效的.
//for instance.
//Ill fill in '"test()"' in the field.
<input type="text" name="input" value="'"test()"'">
$injection = $_POST/*(or $_GET)*/['input']; // coming from the input
public function test(){
echo "injection successful";
}
Run Code Online (Sandbox Code Playgroud)
这可能吗?