没有合适的资源?快使用搜索试试~ 我知道了~
首页C#编程入门实践:环境配置与基础操作
C#编程入门实践:环境配置与基础操作
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 25 浏览量
更新于2024-06-26
收藏 94KB DOCX 举报
本资源是一份关于C#程序设计的实验文档,旨在帮助学生通过实践加深对C#语言的理解和应用。实验共分为两部分:实验一和实验二。 实验一主要关注C#编程环境的配置和基础编程示例。首先,学生需要熟悉并安装C#开发环境,如Visual Studio,以便后续编写代码。实验1-1要求编写一个控制台程序,通过`Console.WriteLine`函数输出"HelloWorld!",展示了如何使用C#的基本输出功能。接着,实验1-2扩展到Windows应用程序,创建了一个名为`Form1`的窗体,利用`MessageBox.Show`方法在用户界面显示消息,进一步熟悉了GUI编程。 实验二深入探讨了C#编程的基础概念。它涵盖了数据类型、常量和变量的使用,包括基本的数据类型如整型、浮点型和字符型,以及如何声明和初始化这些变量。学生还将学习C#的运算符和表达式,理解如何使用条件语句(如if-else)、循环语句(如for和while)来控制程序流程。实验内容特别设计了一个实际问题,即通过分析甲、乙、丙三人的猜测,让学生运用数组来表示四个盒子和球的颜色关系,以此练习数组的定义、初始化和应用。 通过这两个实验,学生不仅能检验他们的理论知识,还能提高实际编程技能,包括环境配置、基本语法运用、数据结构理解和逻辑思维。通过解决实验中的问题,学生能够更好地理解和掌握C#编程语言的核心要素,为以后的项目开发打下坚实的基础。
资源详情
资源推荐
![](https://csdnimg.cn/release/download_crawler_static/87659470/bg9.jpg)
public class Test3_1
{
static void Main(string[] args)
{
CRect rect1 = new CRect(1, 3, 6, 4), rect2 = new CRect(rect1);//拷贝构造,通过
重载
Console.Write("Rectangle 2:Height:{0}", rect2.getHeight());
Console.WriteLine(",Width:{0}", rect2.getWidth());
{
CRect rect3 = new CRect();
Console.Write("Rectangle 3:Height:{0}", rect3.getHeight());
Console.WriteLine(",Width:{0}", rect3.getWidth());
}
Console.Write("Total_rects={0}", CRect.total_rects);
Console.WriteLine(",total_rect_area={0}", CRect.total_rect_area);
Console.Read();
}
}
}
}
抓图的结果:
实验 3-2:设计一个图书卡片类 Card,用来保存图书馆卡片分类记录。这个类的成员包括书名、作者、馆藏数
量。至少提供两个方法,store 书的入库处理,show 显示图书信息,程序运行时,可以从控制台上输入需要
入库图书的总量,根据这个总数创建 Card 对象数组,然后输入数据,最后可以选择按书名、作者、入库量排
序
相关的主要代码:
using System;
using System.Collections.Generic;
using System.Text;
namespace SY3_2
{
class Card
{
private string title, author;
private int total;
public Card()
{
![](https://csdnimg.cn/release/download_crawler_static/87659470/bga.jpg)
title = "";
author = "";
total = 0;
}
public Card(string title, string author, int total)
{
this.title = title;
this.author = author;
this.total = total;
}
public void store(ref Card card)//使用 ref 关键字进行引用传递,似乎是它的拷贝构造
{
title = card.title;
author = card.author;
total = card.total;
}
public void show()
{
Console.WriteLine("Title:{0},Author:{1},Total:{2}", title, author, total);
}
public string Title//Title 的属性可读可写
{
get { return title; }
set { title = value; }
}
public string Author
{
get { return author; }
set { author = value; }
}
public string Total
{
get { return Total; }
set { total = int.Parse (value); }
}
}
public class Test3_2
{
剩余46页未读,继续阅读
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![](https://csdnimg.cn/release/wenkucmsfe/public/img/green-success.6a4acb44.png)