write c# script like python
!!! tip 思路
我们主要是想在 C#
实现 Python
的内置函数,并在C#
中可以直接使用, 以便提高简单脚本的编写效率。
!!! tip 欢迎 ❤️
欢迎 任何 PR
!!! tip idea
We aim to implement the built-in function of python in C#
and direct use in C#
to improve the effect.
!!! tip **Welcome** ❤️
welcome any pull request
- time: 2023年5月15日
- version: 1.0.6
- log:
- change readme
- add
help
function - add
dir
function - fix trim
print()
last sep
more information, see CHANGELOG.md
Code
🔗 C# #r "nuget: CScripting, *"
using static CScripting;
var addr = 0x12345678;
var addrr = hex(addr);
print(addr); // 305419896
print(addrr);
var val = 0x12345678;
var valr = bin(addr);
print(val); // 305419896
print(valr);
var c = new int[] { 0, 1, 2, 3, 4, 5, 6, 7 };
print(c);
print(c, sep:"\t"); |
🔗 Python #r "nuget: CScripting, *"
addr = 0x12345678
addrr = hex(addr)
print(addr) # 305419896
print(addrr)
val = 0x12345678
valr = bin(addr)
print(val); # 305419896
print(valr)
c = [0, 1, 2, 3, 4, 5, 6, 7]
print(c)
print(c, sep="\t") |
Output
C# 305419896
0x12345678
305419896
0b10010001101000101011001111000
{ 0, 1, 2, 3, 4, 5, 6, 7}
0 1 2 3 4 5 6 7 |
Python 305419896
0x12345678
305419896
0b10010001101000101011001111000
[0, 1, 2, 3, 4, 5, 6, 7]
[0, 1, 2, 3, 4, 5, 6, 7] |
~$ dotnet-script
> #r "nuget: CScripting, *"
> using static CScripting;
> hex(1024)
"0x400"
> print("Hello CScripting")
Hello CScripting
- MyOwn
-
load()
-
unload()
-
- coming
-
???
-
????
-
-
A
-
B
-
bin()
-
bool()
-
breakpoint()
-
bytearray()
-
bytes()
-
-
C
-
callable()
-
chr()
-
classmethod()
-
compile()
** -
complex()
**
-
-
D
-
delattr()
-
dict()
-
dir()
* -
divmod()
-
-
E
-
enumerate()
-
eval()
-
exec()
-
-
F
-
filter()
-
float()
-
format()
-
frozenset()
-
-
G
-
getattr()
-
globals()
-
-
H
-
I
-
id()
-
input()
-
int()
-
isinstance()
-
issubclass()
-
iter()
-
-
L
-
len()
-
list()
-
locals()
-
-
M
-
map()
-
max()
-
memoryview()
-
min()
-
-
N
-
next()
-
-
O
-
P
-
pow()
-
print()
-
property()
-
-
R
-
range()
-
repr()
-
reversed()
-
round()
-
-
S
-
set()
-
setattr()
-
slice()
-
sorted()
-
staticmethod()
-
str()
-
sum()
-
super()
-
-
T
-
tuple()
-
type()
-
-
V
- [ ]
vars()
- [ ]
-
Z
-
zip()
-
-
misc
-
_
-
__import__()
-
???
-