在C#中使用模数编码 [英] Coding with Modulus in C#

查看:139
本文介绍了在C#中使用模数编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。我目前正在进行基础编程和逻辑课程。我的项目是创建一个简单的计算器。除了模数按钮,我写了所有内容。我在网上搜索试图找到如何编码,但我无法找到我需要的确切内容。我知道模数可以找到两个数之间的余数。我要做的是将第一个数字输入txtbox,点击模数按钮,然后输入第二个数字并点击相等。我迷失在如何编码这个。请教我一些东西,哦代码大师。我99%完成了这个项目。



谢谢大家,提前花时间回答。

Hello all. I am currently in a Fundamental Programming and Logic class. My project is creating a simple calculator. I have everything written except for the modulus button. I have searched the web trying to find how to code this but am unable to find exactly what I am needing. I understand that modulus finds the remainder between two numbers. What I am trying to do is take the first number entered into the txtbox, hit the modulus button then enter the second number and hit equal. I am lost on how to code this. Please teach me something, oh gurus of code. I''m 99% done with this project.

Thank you all, ahead of time, for taking time to answer.

推荐答案

这是一个你需要的工作实例:



Here is a working example of what you need:

string[] s = TextBox1.Text.ToString().Split(''%'');
       int n = 0;
       if (TextBox1.Text.ToString().Contains("%"))
       {

           n = Convert.ToInt32(s[0].ToString()) % Convert.ToInt32(s[1].ToString());
       }
       Label1.Text = n.ToString();


这篇关于在C#中使用模数编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆