C# 学习之旅(1)
第一, 输入输出流都来自控制台。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int year = int.Parse(System.Console.ReadLine());
int month = int.Parse(System.Console.ReadLine());
int day = int.Parse(System.Console.ReadLine());
int days = fun(year, month, day);
Console.WriteLine("{0}年{1}月{2}日是该年的第{3}天。", year, month, day, days);
Console.ReadLine();
} static int fun(int year, int month, int day)
{
int[] mon = new int[]{,,,,,,,,,,,};
if ((year % == && year % != ) || year % == )
mon[] = ;
int days = ;
for (int i=; i < month - ; i++)
days = mon[i] + days;
days = days + day;
return days;
}
}
}

第二, 输入输出都来自于窗口的textBox。
下面的的代码是双击“按钮”键之后的程序段
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
int year = int.Parse(textBox1.Text);
int month = int.Parse(textBox2.Text);
int day = int.Parse(textBox3.Text);
int days = fun(year, month, day);
textBox4.Text = string.Format("{0}年{1}月{2}日是该年的第{3}天",year,month,day,days);
} static int fun(int year, int month, int day)
{
int[] mon = new int[] { , , , , , , , , , , , };
if ((year % == && year % != ) || year % == )
mon[] = ;
int days = ;
for (int i = ; i < month - ; i++)
days = mon[i] + days;
days = days + day;
return days;
}
}
}

第三, 输入输出都来自于网页上的TextBox(表格)。
下面的的代码是双击“按钮”键之后的程序段
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls; namespace WebApplication1
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ } protected void Button1_Click(object sender, EventArgs e)
{
int year = int.Parse(TextBox1.Text);
int month = int.Parse(TextBox2.Text);
int day = int.Parse(TextBox3.Text);
int days = fun(year, month, day);
TextBox4.Text = string.Format("{0}年{1}月{2}日是该年的第{3}天", year, month, day, days);
} static int fun(int year, int month, int day)
{
int[] mon = new int[] { , , , , , , , , , , , };
if ((year % == && year % != ) || year % == )
mon[] = ;
int days = ;
for (int i = ; i < month - ; i++)
days = mon[i] + days;
days = days + day;
return days;
}
}
}

———————————————————————————————————————————————————————————————————————————
声明:
本文为 大Yi巴狼 对自己所学的知识整理和实现。
本文档欢迎自由转载,但请务必保持本文档完整或注明来之本文档。本文档未经 大Yi巴狼 同意,不得用于商业用途。最后,如果您能从这个简单文档里获得些许帮助,大Yi巴狼 将对自己的一点努力感到非常高兴;由于作者本人水平有限,如果本文档中包含的错误给您造成了不便,在此提前说声抱歉。
祝身体健康,工作顺利。
C# 学习之旅(1)的更多相关文章
- WCF学习之旅—第三个示例之四(三十)
上接WCF学习之旅—第三个示例之一(二十七) WCF学习之旅—第三个示例之二(二十八) WCF学习之旅—第三个示例之三(二十九) ...
- Hadoop学习之旅二:HDFS
本文基于Hadoop1.X 概述 分布式文件系统主要用来解决如下几个问题: 读写大文件 加速运算 对于某些体积巨大的文件,比如其大小超过了计算机文件系统所能存放的最大限制或者是其大小甚至超过了计算机整 ...
- WCF学习之旅—第三个示例之二(二十八)
上接WCF学习之旅—第三个示例之一(二十七) 五.在项目BookMgr.Model创建实体类数据 第一步,安装Entity Framework 1) 使用NuGet下载最新版的Entity Fram ...
- WCF学习之旅—第三个示例之三(二十九)
上接WCF学习之旅—第三个示例之一(二十七) WCF学习之旅—第三个示例之二(二十八) 在上一篇文章中我们创建了实体对象与接口协定,在这一篇文章中我们来学习如何创建WCF的服务端代码.具体步骤见下面. ...
- WCF学习之旅—WCF服务部署到IIS7.5(九)
上接 WCF学习之旅—WCF寄宿前的准备(八) 四.WCF服务部署到IIS7.5 我们把WCF寄宿在IIS之上,在IIS中宿主一个服务的主要优点是在发生客户端请求时宿主进程会被自动启动,并且你可以 ...
- WCF学习之旅—WCF服务部署到应用程序(十)
上接 WCF学习之旅—WCF寄宿前的准备(八) WCF学习之旅—WCF服务部署到IIS7.5(九) 五.控制台应用程序宿主 (1) 在解决方案下新建控制台输出项目 ConsoleHosting.如下 ...
- WCF学习之旅—WCF服务的Windows 服务程序寄宿(十一)
上接 WCF学习之旅—WCF服务部署到IIS7.5(九) WCF学习之旅—WCF服务部署到应用程序(十) 七 WCF服务的Windows 服务程序寄宿 这种方式的服务寄宿,和IIS一样有一个一样 ...
- WCF学习之旅—WCF服务的WAS寄宿(十二)
上接 WCF学习之旅—WCF服务部署到IIS7.5(九) WCF学习之旅—WCF服务部署到应用程序(十) WCF学习之旅—WCF服务的Windows 服务程序寄宿(十一) 八.WAS宿主 IIS ...
- WCF学习之旅—WCF服务的批量寄宿(十三)
上接 WCF学习之旅—WCF服务部署到IIS7.5(九) WCF学习之旅—WCF服务部署到应用程序(十) WCF学习之旅—WCF服务的Windows 服务程序寄宿(十一) WCF学习之旅—WCF ...
- WCF学习之旅—第三个示例之五(三十一)
上接WCF学习之旅—第三个示例之一(二十七) WCF学习之旅—第三个示例之二(二十八) WCF学习之旅—第三个示例之三(二十九) WCF学习 ...
随机推荐
- laravel controller:make
php artisan make:controller DIR/XXXController
- HBase-配置说明
转载自:http://www.aboutyun.com/thread-7914-1-1.html hbase.rootdir这个目录是region server的共享目录,用来持久化Hbase.UR ...
- STL之heap
STL的堆操作 STL里面的堆操作一般用到的只有4个:make_heap();.pop_heap();.push_heap();.sort_heap(); 他们的头文件函数是#include < ...
- Storm中的LocalState 代码解析
官方的解释这个类为: /** * A simple, durable, atomic K/V database. *Very inefficient*, should only be * used f ...
- jQuery中利用JSONP解决AJAX跨域问题
写在前面 跨域的解决方案有多种,其中最常见的是使用同一服务器下的代理来获取远端数据,再通过ajax进行读取,而在这期间经过了两次请求过程,使得获取数据的效率大大降低,这篇文章蓝飞就为大家介绍一下解决跨 ...
- mysql颠覆实战笔记(六)--商品系统设计(三):商品属性设计之固定属性
今天我们来讲一下商品属性 我们知道,不同类别的商品属性是不同的. 我们先建一个表prod_class_attr:
- Android ExpandableListView的技巧和问题
前言: 最近一个多月在认真的学习Android和做项目,文章内容表达的不好或者理解错了,希望大家评论指出. :-) 本文是总结几个比较常用且使用的技巧,和一个大家都会遇到的问题. 文章中大部分语句摘抄 ...
- [改善Java代码]适时选择getDeclaredxxx和getxxx
Java的Class类提供了很多的getDeclaredxxx方法和getxxx方法,例如getDeclaredmethod和getMethod成对出现,getDeclaredConstructors ...
- Eclipse 中引用其他项目及项目打包
1.建立工程project1; 2.建立class文件ClassA: package com.test; public class ClassA{ public static String getCl ...
- ActiveMQ(5.10.0) - 删除闲置的队列或主题
方法一 通过 ActiveMQ Web 控制台删除. 方法二 通过 Java 代码删除. ActiveMQConnection.destroyDestination(ActiveMQDestinati ...