当前位置:网站首页>【UiPath2022+C#】UiPath 练习和解决方案-变量、数据类型和控制流程
【UiPath2022+C#】UiPath 练习和解决方案-变量、数据类型和控制流程
2022-08-05 05:17:00 【会敲键盘的肘子】
【UiPath2022+C#】UiPath 练习-变量、数据类型和控制流程
文章目录
环境
UiPath Studio Community 2022.4.3
Windows
C#
练习
练习 1 - 遍历循环和 If 语句
查找数组中的最小数和最大数
使用“遍历循环”、“分配”和“If 语句”查找 Int32 元素数组中的最小数和最大数,然后打印结果。
注意:您可以使用 {7, 5, 2, 4, 3, 9} 或自定义值(只要是整数)实例化数组。
解决方案
C#解决方案
创建一个静态类
public static class MaxMin
{
private static bool Check(int[] intArray)
{
if (intArray.Length <= 0)
return false;
return true;
}
public static int? Max(int[] intArray)
{
if (MaxMin.Check(intArray))
{
int max = intArray[0];
for (int i = 0; i < intArray.Length; i++)
{
if (intArray[i] > max)
max = intArray[i];
}
return max;
}
else
return null;
}
public static int? Min(int[] intArray)
{
if (MaxMin.Check(intArray))
{
int min = intArray[0];
for (int i = 0; i < intArray.Length; i++)
{
if (intArray[i] < min)
min = intArray[i];
}
return min;
}
else
return null;
}
}
调用该静态类方法
class Program
{
static void Main(string[] args)
{
int[] intArray = new int[] { 7, 5, 2, 4, 3, 9 };
Console.WriteLine($"最大值{MaxMin.Max(intArray)}");
Console.WriteLine($"最小值{MaxMin.Min(intArray)}");
}
}
UiPath解决方案
练习 2 - 泛型值
添加和连接泛型值变量
在序列中创建四个通用值类型变量:
- A,值为“123”
- B,值为“456”
- C,值为 123
- D,值为 456
将以下各变量运算打印到控制台并查看结果:
- A + B
- C + D
- A + C
- C + A
解决方案
练习 3 - 切换
使用“切换”划分错误代码集合
假设有一个存储在字符串数组中的错误代码集合,根据错误代码类型(“Ax”、“Bx”或“Cx”)将其划分为几个类别,并分别存储在 3 个不同的数组中。
注意:初始数组应包含以下值:
“Ax001”、“Ax002”、“Ax003”、“Ax004”、“Ax005”、“Bx001”、“Bx002”、“Bx003”、“Cx001”、“Cx002”、“Cx003”、“Cx004”
解决方案
流程和变量
switch
Add To Collection 配置
文档
边栏推荐
- 哥廷根大学提出CLIPSeg,能同时作三个分割任务的模型
- 伪RTOS-ProroThread在CH573芯片上的移植
- [Database and SQL study notes] 8. Views in SQL
- GIS面试问题
- It turns out that the MAE proposed by He Yuming is still a kind of data enhancement
- 【数据库和SQL学习笔记】7.SQL中的插入(INSERT)、删除(DELETE)、更新(UPDATE)
- 电子产品量产工具(1)- 显示系统实现
- C语言—扫雷的实现
- MySQL主从复制—有手就能学会的MySQL集群搭建教程
- 【ts】typescript高阶:条件类型与infer
猜你喜欢
随机推荐
基于STM32F407的一个温度传感器报警系统(用的是DS18B20温度传感器,4针0.96寸OLED显示屏,并且附带日期显示)
IJCAI 2022|边界引导的伪装目标检测模型BGNet
TinyFlashDB:一种超轻量的可纠错的通用单片机flash存储方案
LeetCode刷题之第701题
Tensorflow steps on the pit notes and records various errors and solutions
七、请求处理——Map、Model类型参数处理原理
CVPR 2020 - 频谱正则化
GIS面试问题
Redis集群(docker版)——从原理到实战超详细
Facial Motion Capture 调研
【ts】typescript高阶:typeof使用
CH32V307 LwIP移植使用
十一、拦截器运行原理
关于存储IOPS你必须了解的概念
LeetCode刷题之第530题
【ts】typescript高阶:键值类型及type与interface区别
LeetCode刷题之第86题
ACL 的一点心得
【ts】typescript高阶:分布式条件类型
ECCV2022 | RU&谷歌提出用CLIP进行zero-shot目标检测!