小编Zee*_*eee的帖子

C#简单的"Hello World"在控制台中缺少一行代码?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
class Program
{
    static void Main(string[] args)
    {
        string userName = "";
        int userAge = 0;
        int currentYear = 0;

        Console.Write("Please enter your name: ");
            userName = Console.ReadLine();
        Console.Write("Please enter your age: ");
        userAge = Convert.ToInt32(Console.ReadLine());
        Console.Write("Please enter the current year: ");
        currentYear = Convert.ToInt32(Console.ReadLine());

        Console.WriteLine("Hello World, my name is {0} and I'm {1} years old, I was born on the year {2} .", userName, userAge, currentYear …
Run Code Online (Sandbox Code Playgroud)

c# visual-studio

3
推荐指数
1
解决办法
223
查看次数

C#需要解释涉及类的变量的事情

所以它说:

public int HoursWorked { get; set; }
Run Code Online (Sandbox Code Playgroud)

相当于......

private int hWorked;
public int HoursWorked
{
    get
    {
        return hWorked;
    }
    set
    {
        hWorked = value;
    }
}
Run Code Online (Sandbox Code Playgroud)

我有两个问题......

  1. 简单地调用"HoursWorked"的简单命令如何将"hWorked"带入其中?

  2. 我也不完全明白"价值"的价值是什么

感谢您的帮助!

c# visual-studio

2
推荐指数
1
解决办法
63
查看次数

在 C++ 中将字符串转换为链接字符列表时遇到问题

我已经在这方面工作了一段时间,目前我很难过。该程序的起始要求是接受一个字符串,为该类创建一个对象,并将其转换为一个字符链表。我在整个类中遇到了麻烦,因为当我尝试在 while 循环之前的 Main 函数中预定义一个新对象时,我收到错误charchain.cpp:(.text+0x20): undefined reference to linkedChar::linkedChar()我已经测试了该课程并成功转换为字符链表。

#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

    struct node { 
    char data; 
    node* next; 
}; 
class linkedChar
{
    private:
    node* head;
    
    public:
    string str;
    linkedChar();
    linkedChar(const std::string s){
        head = NULL;
        strToLinkedChar(s);
    }
    

node* add(char data) 
{ 
    node* newnode = new node; 
    newnode->data = data; 
    newnode->next = NULL; 
    return newnode; 
}

node* strToLinkedChar(string str){ 
    head = add(str[0]); 
    node* curr = head; 
   
    for (int i = 1; i …
Run Code Online (Sandbox Code Playgroud)

c++ class linked-list object nodes

0
推荐指数
1
解决办法
62
查看次数

标签 统计

c# ×2

visual-studio ×2

c++ ×1

class ×1

linked-list ×1

nodes ×1

object ×1