-当没有跟随时,我需要拆分角色CMB
例
测试数据
abcd-sdfsdf-cmb
sdfsdf-cmb
Run Code Online (Sandbox Code Playgroud)
预期输出
abcd
sdfsdf-cmb
abcd-cmb
sdfsdf
Run Code Online (Sandbox Code Playgroud)
到目前为止我有什么
Regex.Split(operation, @"-+")
Run Code Online (Sandbox Code Playgroud)
返回
abcd
sdfsdf
cmb
abcd
cmb
sdfsdf
Run Code Online (Sandbox Code Playgroud)
注意上面只是返回一个分裂,-
但我不知道如何展望未来CMB
任何帮助将不胜感激,谢谢
我收到编译器错误
CS1061“MAUserVM”不包含“GetAwaiter”的定义,并且找不到接受“MAUserVM”类型的第一个参数的可访问扩展方法“GetAwaiter”(您是否缺少 using 指令或程序集引用?)
异步方法
public class MAUserVM
{
public string AuthenticationStatus;
public MAUser mAUser;
public async Task<MAUserVM> GetMAUserAsync(string Email, string Password, IConfiguration configuration, IHttpContextAccessor accessor)
{
...
}
}
Run Code Online (Sandbox Code Playgroud)
调用方法
private async Task<Boolean> AuthenticateUser(string email, string password)
{
...
// exception happening here
userVM = await userVM.GetMAUserAsync(email, password, _configuration, _accessor).Result;
...
}
Run Code Online (Sandbox Code Playgroud)
是什么原因造成的?
我正在为员工的贷款计划付款做一些计算,我一直在努力
ClassName:"System.DivideByZeroException",消息:"试图除以零."
我不知道我做错了什么,也许我没有把小数点好.
private static decimal ReturnPayments(decimal loanAmount, int durationMonths, decimal interestMonthly)
{
return (loanAmount * interestMonthly)/ (decimal) (1-Math.Pow((int)(1
+ interestMonthly), -durationMonths));
}
public IEnumerable<LoanRepaymentSchedule> GetRepayment(string employeeId, decimal principalAmt, decimal rate, int terms)
{
var employee = _employeeService.FindByAsync(e => e.Id == employeeId
&& e.Status == EntityStatus.Active).Result;
var results = employee.FirstOrDefault();
var currentBalance = principalAmt - 0;
decimal monthlyRate = rate / 1200;
var monthlyPaymentAmt = ReturnPayments(currentBalance, terms, monthlyRate);
var result = new List<LoanRepaymentSchedule>();
for (var currentPayment =1; currentPayment<= terms; currentPayment++) …Run Code Online (Sandbox Code Playgroud) 通常的方法是
public datatype name(parameters) {}
Run Code Online (Sandbox Code Playgroud)
是否可以使用没有参数的整数方法?如果是这样怎么办?
例:
public int WorkPlease(){}
Run Code Online (Sandbox Code Playgroud) 完全菜鸟到 C#,从 Visual Basic 转换,我一直在尝试在单独的模块中引用类字段,尝试了一切,都不好。将所有内容移至一个模块以最大程度地减少可访问性问题,将所有内容都设置为公共范围,但仍然无法访问字段/属性。我已经把它归结为绝对的基础知识,但仍然无法让它发挥作用。尝试了所有可能的可访问性变化(我认为)。
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Car MyCar = new Car();
}
public class Car
{
string Manufacturer { get; set; }
string Model { get; set; }
int YearMade { get; set; }
}
private void button1_Click(object sender, EventArgs e)
{
Car.Manufacturer = "Ford";
}
}
Run Code Online (Sandbox Code Playgroud)
Car.Manufacturer 在 Click 事件中抛出
CS0122 'Form1.Car.Manufacturer' 由于其保护级别而无法访问。
如果我将制造商字段更改为公共我会收到此错误:
CS0120 非静态字段、方法或属性“Form1.Car.Manufacturer”需要对象引用
我意识到我在这里做了一些愚蠢的事情,但这有多难?