File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed
Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 33![ ] ( https://img.shields.io/github/v/release/Jayshonyves/JxCode.LuaSharp?style=for-the-badge )
44![ ] ( https://img.shields.io/github/release-date/Jayshonyves/JxCode.LuaSharp?style=for-the-badge )
55
6- 该库提供了类型系统、常用容器、常用类库与异常处理等工具,可以轻量开发简单的程序,本着lua语言的定位,该库并不会增加更多繁重的内容,复杂功能推荐使用宿主语言实现。
6+ 该库提供了类型系统、常用容器、常用类库与异常处理等工具,拥有实用且轻量的工具可以轻量开发简单的程序,本着lua语言的定位,该库并不会增加更多繁重的内容,复杂功能推荐使用宿主语言实现。
7+
8+ ``` lua
9+ local n = (" notice: {0} {1} - {2}" ):Format (" hello" , " Syslib" , 2.0 )
10+ ```
11+
712## Feature
813* 拥有C#关键字与类型系统的Lua面向对象系统,拥有常用的容器、类库、try-catch异常处理等工具,更适用于熟悉.Net的Lua/Unity开发者。
914* 本框架使用Pascal命名规则,核心级函数(关键字)为全小写,私有成员可以使用m_member或者__ menmber来提醒其他开发者不要来使用该成员。
1520 - [ Contents] ( #contents )
1621 - [ 将库引入项目] ( #将库引入项目 )
1722 - [ 类型与对象] ( #类型与对象 )
18- - [ 迭代器] ( #迭代器 )
1923 - [ 字符串] ( #字符串 )
2024 - [ 位运算] ( #位运算 )
2125 - [ 枚举类型与Flag] ( #枚举类型与flag )
2226 - [ 运算符重载] ( #运算符重载 )
2327 - [ 类型转换] ( #类型转换 )
28+ - [ 迭代器] ( #迭代器 )
2429 - [ 容器] ( #容器 )
2530 - [ 抛出异常与捕捉异常] ( #抛出异常与捕捉异常 )
2631 - [ 文件处理] ( #文件处理 )
@@ -96,8 +101,6 @@ Object.Equals(tc, target)
96101local Manamger = class .static (" Manamger" )
97102```
98103
99- ## 迭代器
100-
101104## 字符串
102105可以让字符串变量当做对象来使用,例如
103106``` lua
@@ -192,6 +195,11 @@ local cbo3 = bool.Parse("true")
192195```
193196BitConverter
194197
198+ ## 迭代器
199+ lua默认的迭代器只可以对table进行访问,但是该库的四大容器并不是直接储存在table中,这也是为了避免原方法被覆盖,所以可以使用each来遍历四大迭代器。
200+ 如果想继续使用lua原生迭代器,可以使用容器的GetEnumerator方法获取迭代器。
201+ 同样的,容器需要扩展时
202+
195203## 容器
196204常用的List和Dictionary实现了GetEnumerator方法,可以直接使用each迭代器,同时也支持lua原版的ipairs与pairs迭代器,并且容器拥有ForEach方法迭代器。
197205``` lua
Original file line number Diff line number Diff line change @@ -15,6 +15,10 @@ Console.WriteLine("LastIndexOf: "..tostring(str:LastIndexOf('o')))
1515local space = " " .. str .. " "
1616Console .WriteLine (" Trim: " .. space :Trim ())
1717
18+ -- Format
19+ local time = (" time: {0}:{1}" ):Format (20 , 36 )
20+ assert (time == " time: 20:36" )
21+
1822-- 中文字符的长度获取
1923local zhStr = " Hello渔"
2024Console .WriteLine (" zhStr len: " .. tostring (zhStr :Length ())) -- result: 8
@@ -26,6 +30,8 @@ Console.WriteLine("charArr: "..Serialization.Serialize(strCharArr))
2630local newStr = String .New (strCharArr )
2731Console .WriteLine (" NewString: " .. newStr )
2832
33+
34+ -- StringBuilder
2935local sb = StringBuilder .New ()
3036sb :Append (" hello" )
3137sb :AppendLine (" world" )
You can’t perform that action at this time.
0 commit comments