我最近安装了 C++,以便重新学习该语言(已经完成了一些小项目)。真正让我烦恼的一件事是,实现时的自动完成功能不再起作用。
更具体地说,自动完成参数和函数名称。我已经在各自的标头中声明了我的类和函数。虽然我的记忆有点模糊,但我记得在2008年,一旦你在cpp文件中输入名称,它会自动给你一个相应参数的下拉框。
然后我搜索了论坛和页面以寻找可能的解决方案,并得知智能感知功能已从新的 VS 2010 中的 C++ 环境中删除(为什么?)。但可以通过以下方式检索参数列表:
(1) 检查“工具 -> 文本编辑器 -> C++ -> 自动列表成员”,并在高级选项卡中查看该功能是否已禁用。
(2) 使用 Ctrl-完成陈述时留出空格。
我已经尝试过这两种方法,但它们不起作用(并且我读过一些论坛,认为 ctrl+space 至少应该在某种程度上起作用)。声明应该是正确的,因为当我定义函数并右键单击并将名称命名为“转到声明”时,它将突出显示头文件中的声明(其中提供了整个参数列表)。Ctrl+J 会告诉我 VS 确实识别函数声明。
我不想使用第三方软件,例如(视觉辅助 X),但我已经没有选择了。
预先非常感谢您。
在Form_load中我有
txtAlteFonduri.Text = "5,00";
txtFReparatii.Text = "15,00";
txtFRulment.Text = "20,00";
Run Code Online (Sandbox Code Playgroud)
在另一个函数中,我想将文本解析为十进制
decimal alteFonduri = Decimal.Parse(txtAlteFonduri.Text);
decimal fondRulment = Decimal.Parse(txtFRulment.Text);
decimal fondRepar = Decimal.Parse(txtFReparatii.Text);
Run Code Online (Sandbox Code Playgroud)
但我在第二行有一个错误
Input string was not in a correct format.
Run Code Online (Sandbox Code Playgroud) 我使用C#使用Visual Studio 2010创建了一个表单.我想创建并保存它的png图片(Form1.cs [design]).
我编写了一个程序,使用随机键对文本进行编码。使用密钥时,即使我仅使用一个字母进行编码,解码器的结果也是完全错误的
这是用于加密/解密的函数,以及用于生成具有确定长度的随机密钥的函数:
string XOR_String(string text, string key)
{
var result = new StringBuilder();
for (int c = 0; c < text.Length; c++)
result.Append((char)((uint)text[c] ^ (uint)key[c % key.Length]));
return result.ToString();
}
private static string RandomString(int Size)
{
Random random = new Random();
string input = "abcdefghijklmnopqrstuvwxyz0123456789";
var chars = Enumerable.Range(0, Size)
.Select(x => input[random.Next(0, input.Length)]);
return new string(chars.ToArray());
}
Run Code Online (Sandbox Code Playgroud)
解密:
private void button1_Click(object sender, EventArgs e)
{
openFileDialog1.FileName = "data.txt";
openFileDialog1.Title = "Open file";
openFileDialog1.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.Personal);
if (openFileDialog1.ShowDialog() == DialogResult.OK) …Run Code Online (Sandbox Code Playgroud) 我对编程很新,而且我已经意识到人们不喜欢"goto"-methods.我想知道如何编写允许用户决定输入多少条目的代码?例如,在下面的代码中,用户输入一个名称,然后询问他/她是否想要输入另一个名字.我怎么能这样做而不必使用go-to方法?
public class GoToTest
{
public static void Main()
{
InputName:
string name;
Console.Write("Input name: ");
name = Console.ReadLine();
string decision;
Console.WriteLine(""); //Empty line for increased readability
Console.WriteLine("Would you like to input another name? Yes - No");
decision = Console.ReadLine();
if (decision == "Yes")
{
goto InputName;
}
else
{
Console.WriteLine("Name is " + name);
}
}
}
Run Code Online (Sandbox Code Playgroud) 好的,我想从控制台输入一个整数,并检查数字是否为素数.我挖出了一个代码,然后根据我的需要对其进行了转换,但计算不正确.
using System;
class PrimeNumber
{
static void Main()
{
Console.Write("Type a number: ");
string line = Console.ReadLine(); // Read string from console
int value;
if (int.TryParse(line, out value)) // Try to parse the string as an integer
{
int x = 0;
if (value == 1) Console.WriteLine("not prime");
if (value == 2) Console.WriteLine("prime");
for (int i = 3; i < value*value; i+=2)
{
if (value % 2 == 0) x++; break;
if (value % i == 0) x++; break; …Run Code Online (Sandbox Code Playgroud)