定位问题

程序中往往涉及定位问题,定位有两种办法:

1、起点+大小

2、起点+终点

二者本质上一样,C#中大多采用起点+大小的办法,比如C# String的方法 Substring(int startIndex, int length)

Java中大多采用起点+终点的办法,比如Java String的方法 substring(int beginIndex,  int endIndex)

其实 起点+大小 更为合适,大多数情况下,我们的使用场景是:知道起点和大小。比如,在WPF中Grid的用法。

View Code
 1         <Grid>
2 <Grid.RowDefinitions>
3 <RowDefinition />
4 <RowDefinition />
5 <RowDefinition />
6 </Grid.RowDefinitions>
7
8 <Grid.ColumnDefinitions>
9 <ColumnDefinition />
10 <ColumnDefinition />
11 <ColumnDefinition />
12 <ColumnDefinition />
13 </Grid.ColumnDefinitions>
14
15 <Button Grid.Row="1" Grid.Column="1" Grid.RowSpan="2" Grid.ColumnSpan="3">起点为(1,1),大小为(2*3)</Button>
16 </Grid>
原文地址:https://www.cnblogs.com/nzbbody/p/2312288.html