简体   繁体   English

区分运算符和操作数

[英]differentiate between operator and operand

I have a few questions regarding operators and operands. 我对运算符和操作数有一些疑问。 Take a look at these code samples: 看一下这些代码示例:

Random r = new Random();
foreach(List<Point3d> individual in sG)
{
    index1 = r.Next(0, individual.Count);
    distance = actual.DistanceTo(next);
}

I know that these are the operators: 我知道这些是运算符:

foreach() -- () -- ; -- = -- . -- , -- new

And I know that these are operands: 而且我知道这些是操作数:

r -- individual -- sG -- index1 -- distance -- actual -- next -- 0

However what is with: 但是,这是什么:

List<Point3d> -- in -- Next -- individual.Count -- DistanceTo -- Random

I'm guessing that List<Point3d> should be an operand and DistanceTo an operator but not sure at all. 我猜想List<Point3d>应该是一个操作数,而DistanceTo应该是一个运算符,但根本不确定。

For your information, I'm trying to calculate the Halstead Metrics for my genetic algorithm. 供您参考,我正在尝试为我的遗传算法计算Halstead指标。

Here are some links where I got the information. 这是我获得信息的一些链接。 Maybe it will be useful for others in search like myself. 也许对像我这样的其他搜索者有用。 Measurement of Halstead Metrics ; Halstead度量的测量 ; Halstead metrics: Example ; Halstead指标:示例 Halstead Metrics: Example in German Halstead指标:德语示例

List<> It's a Generic Class collection. List <>这是一个通用类集合。 What it stand for is that it's a list of Point3d which is another class. 它代表的是这是另一个类Point3d的列表。

in : it's a reserved word which works with the foreach statement. in :这是一个保留字,可与foreach语句配合使用。 It means iterate for each element IN sG (which is a variable with lots of List and put the current element in the "individual" variable. 这意味着对每个元素IN sG进行迭代(这是一个具有大量List的变量,并将当前元素放入“单个”变量中)。

.DistanceTo, .Next, .Count, .Random, etc are methods and properties of each class. .DistanceTo,.Next,.Count,.Random等是每个类的方法属性

I recomend you to read something about Object Oriented Programming before continue with that algorigthm... 我建议您在继续使用该算法之前先阅读一些有关面向对象编程的知识。

in - is operator in -为运营商
Random , List<Point3d> - are Types RandomList<Point3d> -是类型
.Next() , .DistanceTo() - are functions .Next() .DistanceTo() -是函数
individual.Count - is property individual.Count是属性

More about these all you can read Here 有关这些的更多信息,您可以在这里阅读

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM