当前位置:网站首页>c语言hello world代码(代码编程入门)
c语言hello world代码(代码编程入门)
2022-07-31 14:25:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
using System;
using System.Collections.Generic;
public class MyClass
{
struct Name{
public string FirstName;
public string LastName;
public string GetName(){
return FirstName + "·" + LastName;
}
}
struct Vector3{
public float x;
public float y;
public float z;
public double Distance(){
return Math.Sqrt(x*x+ y*y+ z*z);
}
}
public static void RunSnippet()
{
Name myName;
myName.FirstName = "Alexander";
myName.LastName = "Azhar";
System.Console.WriteLine("My name is " + myName.GetName());
Vector3 point;
System.Console.WriteLine("Please enter three points' position to calculate its distance: ");
point.x = Convert.ToInt32(System.Console.ReadLine());
point.y = Convert.ToInt32(System.Console.ReadLine());
point.z = Convert.ToInt32(System.Console.ReadLine());
System.Console.WriteLine("The Sqrt distance of the three points is "+point.Distance()+" .");
}
#region Helper methods
public static void Main()
{
try
{
RunSnippet();
}
catch (Exception e)
{
string error = string.Format("---\nThe following error occurred while executing the snippet:\n{0}\n---", e.ToString());
Console.WriteLine(error);
}
finally
{
Console.Write("Press any key to continue...");
Console.ReadKey();
}
}
private static void WL(object text, params object[] args)
{
Console.WriteLine(text.ToString(), args);
}
private static void RL()
{
Console.ReadLine();
}
private static void Break()
{
System.Diagnostics.Debugger.Break();
}
#endregion
}
上面代码的结构一定要记住,因为结构比较好,所以和大家分享。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/128463.html原文链接:https://javaforall.cn
边栏推荐
- Redis与分布式:主从复制
- In the future, the interviewer asks you why it is not recommended to use Select *, please answer him out loud!
- [QNX Hypervisor 2.2 User Manual] 9.13 rom
- For enterprises in the digital age, data governance is difficult, but it should be done
- jOOQ 3.14 released - SQL/XML and SQL/JSON support
- 纸质说明书秒变3D动画,斯坦福大学吴佳俊最新研究,入选ECCV 2022
- OAuth2:四种授权方式
- Shell脚本经典案例:探测批量主机是否存活
- MySQL [subquery]
- Comparison of Optical Motion Capture and UWB Positioning Technology in Multi-agent Cooperative Control Research
猜你喜欢
UnityShader入门学习(一)——GPU与Shader
sentinel与nacos持久化
The 232-layer 3D flash memory chip is here: the single-chip capacity is 2TB, and the transmission speed is increased by 50%
纸质说明书秒变3D动画,斯坦福大学吴佳俊最新研究,入选ECCV 2022
IDEA connects to MySQL database and uses data
Selenium自动化测试之Selenium IDE
49.【拷贝构造函数与重载】
Uniapp WeChat small application reference standard components
1小时直播招募令:行业大咖干货分享,企业报名开启丨量子位·视点
架构实战营模块8消息队列表结构设计
随机推荐
AWS实现定时任务-Lambda+EventBridge
线程池的使用二
常用工具命令速查表
Sentinel热点参数限流
LeetCode只出现一次的数字
Prometheus之node_exporter性能监控信息采集含义
Comparison of Optical Motion Capture and UWB Positioning Technology in Multi-agent Cooperative Control Research
Five dimensions to start MySQL optimization
ML、DL、CV常见的问题整理
技能大赛训练题:交换机虚拟化练习
1小时直播招募令:行业大咖干货分享,企业报名开启丨量子位·视点
Unity Shader入门精要学习——透明效果
Redis与分布式:哨兵模式
技能大赛训练题: 子网掩码划分案例
Shell script classic case: backup of files
jvm 一之 类加载器
Why do we need to sub-library and sub-table?
An article makes it clear!What is the difference and connection between database and data warehouse?
多智能体协同控制研究中光学动作捕捉与UWB定位技术比较
Open Inventor 10.12 重大改进--和谐版