乔乔lovefreedom

导航

公告

统计

2011年10月17日 #

.NET面试题库(转载)

摘要: 用.net做B/S结构的系统,您是用几层结构来开发,每一层之间的关系以及为什么要这样分层? 答:从下至上分别为:数据访问层、业务逻辑层(又或成为领域层)、表示层 数据访问层:有时候也称为是持久层,其功能主要是负责数据库的访问 业务逻辑层:是整个系统的核心,它与这个系统的业务(领域)有关 表示层:是系统的UI部分,负责使用者与整个系统的交互。 优点: 分工明确,条理清晰,易于调试,而且具有可扩展性。 缺点: 增加成本。分层式结构究竟其优势何在? 1、开发人员可以只关注整个结构中的其中某一层; 2、可以很容易的用新的实现来替换原有层次的实现; 3、可以降低层与层之间的依赖; 4、有利于标准化; 5阅读全文

posted @ 2011-10-17 19:28 乔乔lovefreedom 阅读(81) 评论(0) 编辑

2011年9月7日 #

js

静态页面

<head runat="server">
    <title></title>
    <script src="jquery-1.4.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        function changeCity() {
            var c = $("#Select1").val();
            var bei = $("#Select2");
            var tian = $("#Select3");
            if (c == "1") {
                bei.show();
                tian.hide();
            }
            if (c == "2") {
                bei.hide();
                tian.show();
            }
        }
    </script>
</head>
<body onload="changeCity();">
    <form id="form1" runat="server">
    <div>
            城市:<select id="Select1" onchange="changeCity();">
            <option value="1">北京</option>
            <option value="2">天津</option>
        </select>
        城区:
        <select id="Select2">
            <option value="1">朝阳区</option>
            <option value="2">海淀区</option>
        </select>
        <select id="Select3" >
            <option value="1">和平区</option>
            <option value="2">塘沽区</option>
        </select>
    </div>
    </form>
</body>

-----------------------------------------------------------------------------

支持后台数据

<head runat="server">
    <title></title>
    <script src="jquery-1.4.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        function get() {
            var dataParamter = "city=" + $("#city").val(); ;
            $.ajax({
                type: "POST",
                dataType: "xml",
                url: "Cityaaaa.ashx",
                data: dataParamter,
                success: function (data) {
                    var qu = $("#sel_b"); var op = "";
                    var nodeList = $("node", data);
                    if (nodeList.length > 0) {

                        nodeList.each(function (i) {
                            var nodeID = $(this).children("ID").text();
                            var typeName = $(this).children("name").text();
                            op += "<option value='" + nodeID + "'>" + typeName + "</option>";
                        });
                    }
                    qu.html(op);
                }
            });

        }
    </script>
</head>
<body onload="get();">
    <form id="form1" runat="server">
    <div>
        城市:<select id="city" onchange="get();">
            <option value="1">北京</option>
            <option value="2">天津</option>
        </select>
        城区:
        <select id="sel_b">
        </select>
        <br />
        ------------------------------------------------------------------------------
        <br />

    </div>
    </form>
</body>

 

 

 public class Cityaaaa : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            StringBuilder returnStr = new StringBuilder("<nodes>");

            if (!string.IsNullOrEmpty(context.Request["city"]))
            {
                int level;
                if (int.TryParse(context.Request["city"], out level))
                {
                    if (string.IsNullOrEmpty(context.Request["city"]) == false)
                    {
                        int type;
                        if (int.TryParse(context.Request["city"], out type))
                        {
                            IList<City> codeTypeList = this.GetData(type);
                            if (codeTypeList != null && codeTypeList.Count > 0)
                            {
                                string listStr = GetCodeType(codeTypeList);
                                if (string.IsNullOrEmpty(listStr) == false)
                                {
                                    returnStr.Append(listStr);
                                }
                            }
                        }
                    }
                }
            }
            returnStr.Append("</nodes>");
            context.Response.ContentType = "text/xml";
            context.Response.Write(returnStr.ToString());
        }

        //组建代码扩展信息XML节点串
        private string GetCodeType(IList<City> typeList)
        {
            StringBuilder codeSb = new StringBuilder();
            if (typeList != null && typeList.Count > 0)
            {
                foreach (City code in typeList)
                {
                    codeSb.Append("<node>");
                    codeSb.Append("<ID>" + code.ID + "</ID>");
                    codeSb.Append("<name>" + code.Name + "</name>");
                    codeSb.Append("</node>");
                }
            }
            return codeSb.ToString();
        }

        private IList<City> GetData(int flag)
        {
            IList<City> list = new List<City>();
            switch (flag)
            {
                case 1:
                    list.Add(new City() { ID = 1, Name = "东城区" });
                    list.Add(new City() { ID = 2, Name = "xi城区" });
                    list.Add(new City() { ID = 3, Name = "bei城区" });
                    list.Add(new City() { ID = 4, Name = "nan城区" });
                    break;
                case 2:
                    list.Add(new City() { ID = 1, Name = "111" });
                    list.Add(new City() { ID = 2, Name = "xi222城区" });
                    list.Add(new City() { ID = 3, Name = "bei3333城区" });
                    list.Add(new City() { ID = 4, Name = "nan4444城区" });
                    break;
                default:
                    break;
            }
            return list;
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }

 

。cs文件中的

 

 

posted @ 2011-09-07 01:42 乔乔lovefreedom 阅读(14) 评论(0) 编辑

sql

create table #tmp
(
  name nvarchar(50),
  [subject] nvarchar(50),
  grade float  
)

insert into  #tmp values('张三' ,'语文',90)
insert into  #tmp values('张三' ,'数学',80)
insert into  #tmp values('张三' ,'英语',75)

insert into  #tmp values('李四' ,'语文',75)
insert into  #tmp values('李四' ,'数学',60)
insert into  #tmp values('李四' ,'英语',85)

insert into  #tmp values('王五' ,'语文',85)
insert into  #tmp values('王五' ,'数学',77)
insert into  #tmp values('王五' ,'英语',99)

select * from #tmp;

select name as 姓名,
AVG(case when [subject]='语文' then grade end) as 语文,
AVG(case when [subject]='数学' then grade end) as 数学,
AVG(case when [subject]='英语' then grade end) as 英语
from #tmp
group by #tmp.name

create table #tmp2 --添加物理、化学
(
   姓名 nvarchar(50),
   物理 float,
   化学 float
)

insert into  #tmp2 values('张三' ,75,80)

insert into  #tmp2 values('李四' ,95,85)

insert into  #tmp2 values('王五' ,90,85)

select * from #tmp2;

select a.姓名,a.语文,a.数学,a.英语,b.物理,b.化学 from (
select name as 姓名,
AVG(case when [subject]='语文' then grade end) as 语文,
AVG(case when [subject]='数学' then grade end) as 数学,
AVG(case when [subject]='英语' then grade end) as 英语
from #tmp
group by #tmp.name) a left join #tmp2 b on a.姓名=b.姓名

 

 

posted @ 2011-09-07 00:46 乔乔lovefreedom 阅读(13) 评论(0) 编辑

2011年9月6日 #

delegate

// 可以接受若干参数的委托
    public delegate double Method( params int[] numbers);

    public class Demo
    {


        public double Times( params int[] numbers)
        {
            double result = 1;
            foreach (int i in numbers)
                result *= i;
            return result;
        }

        public double Div(params int[] numbers)
        {
            if (numbers == null || numbers.Length == 0)
                throw new InvalidOperationException("参数错误");
           
            if (numbers.Length == 1)
                return numbers[0];

            double first = numbers[0];
            int length = numbers.Length;

            for (int i = 1; i < length; i++)
            {
                int x = numbers[i];
                if (x == 0)
                    throw new InvalidOperationException("错误的参数");

                first /= x;
            }

            return first;
        }
    }


    public class Calculator
    {

        public Method Times;
        public Method Div;

        public Calculator()
        {
        }

        public double MyTimes(params int[] numbers)
        {
            return this.Times(numbers);
        }

        public double MyDiv(params int[] numbers)
        {
            return this.Div(numbers);
        }

    }

 

    class Program
    {


        static void Main(string[] args)
        {
            // 装配
            Calculator calculator = new Calculator();

            Demo demo = new Demo();

            calculator.Times = demo.Times;
            calculator.Div = demo.Div;

            // 使用计算器
            double r = calculator.MyTimes(1, 2, 3, 4);
            Console.WriteLine(r);

            double r2 = calculator.MyDiv(12, 2, 3);
            Console.WriteLine(r2);
        }}

posted @ 2011-09-06 13:49 乔乔lovefreedom 阅读(9) 评论(0) 编辑

2011年5月5日 #

ASP.NET身份认证

摘要: <?xml version="1.0"?><!-- Note: As an alternative to hand editing this file you can use the web admin tool to configure settings for your application. Use the Website->Asp.Net Configuration option in Visual Studio. A full list of settings and comments can be found in machine.co阅读全文

posted @ 2011-05-05 10:11 乔乔lovefreedom 阅读(172) 评论(0) 编辑

2011年3月16日 #

吃饭美女姐姐给出的算术题

给你1000个苹果,给你10个箱子,苹果可以往箱子里面随便放,我向你要苹果的时候,我肯定是要1000个以内的(含1000个),你必须给我箱子,箱子里面存放着我要的苹果,给我的箱子数目任意,请问,这10个箱子中苹果应该怎么放?

答案:大学的递归算法和数学归纳法思想,我们必须联想到递推的含义,要解决大的问题,就必须在小的问题上进行找规律,所以我们从最基本的做起,我要一个苹果,你必须在某个箱子只能放入一个苹果,我要两个,此时面临的选择是你可以两个箱子各放一个苹果,也可以在某一个箱子放入两个苹果,但是你要考虑到我们只有10个箱子,所以必须要以最小的次数来解决问题,我们选择在某个箱子放入两个苹果,这样,即便是我要三个苹果的时候,你就可以把两个箱子给我,因为两个箱子里面一共装了3个苹果,当我要四个苹果的时候,你不满足,此时你面临的选择,在某个箱子放入一个苹果,在某个箱子放入两个苹果,或者在某个箱子放入四个苹果,因为我们要满足更大的数目,所以我们要在某个箱子放入四个苹果,以此类推,我们放入的苹果为8,16,32,64,128,256,此时要注意,只剩下最后一堆的苹果了,我们算出,现在已经放入箱子的苹果数目为511个,所以最后我们只能放入1000-511 = 489个,此题目的规律类似于斐波那契数列,前面的苹果数目只能满足前面苹果数目相加起来的情况,所以啊,最后一个元素不用考虑是否满足,而是一定满足的,所以最后一个必须为489个,这也检验了一个人是否细心,所以我们必须要学会谨慎的思维,而不能浮躁!

posted @ 2011-03-16 20:08 乔乔lovefreedom 阅读(178) 评论(1) 编辑

对比C#中==与equal方法

 C#中equal与==的区别 收藏
对于值类型,如果对象的值相等,则相等运算符 (==) 返回 true,否则返回 false。对于string 以外的引用类型,如果两个对象引用同一个对象,则 == 返回 true。对于 string 类型,== 比较字符串的值。
==操作比较的是两个变量的值是否相等。
equals()方法比较的是两个对象的内容是否一致.==也就是比较引用类型是否是对同一个对象的引用。

例子:


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = new string(new char[] { 'h', 'e', 'l', 'l', 'o' });
            string b = new string(new char[] { 'h', 'e', 'l', 'l', 'o' });
            Console.WriteLine(a == b);
            Console.WriteLine(a.Equals(b));

            object g = a;
            object h = b;
            Console.WriteLine(g == h);
            Console.WriteLine(g.Equals(h));

            Person p1 = new Person("jia");
            Person p2 = new Person("jia");
            Console.WriteLine(p1 == p2);
            Console.WriteLine(p1.Equals(p2));


            Person p3 = new Person("jia");
            Person p4 = p3;
            Console.WriteLine(p3 == p4);
            Console.WriteLine(p3.Equals(p4));

            Console.ReadLine();
        }
    }
}


输出
true,true,false,true,false,false,true,true。

posted @ 2011-03-16 15:34 乔乔lovefreedom 阅读(510) 评论(0) 编辑

2011年2月14日 #

.NET图片处理

摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Drawing;using System.Drawing.Imaging;using System.IO;using System.Diagnostics;namespace ImageCompressTool{ class Program { static void Main(string[] args) { DateTime start = DateTime.Now; ImageDealTool dea阅读全文

posted @ 2011-02-14 14:34 乔乔lovefreedom 阅读(341) 评论(1) 编辑

2011年1月28日 #

苹果公司的粉丝-转抄

摘要: 1.请先把C语言基础学好; 2.看《Programming in Objective-C 2.0》,不要看《Objective-C 2.0程序设计》; 3.看《Cocoa Design Patterns》和《Cocoa Programming Developer's Handbook》,不要因为他们很难而我们自己是初学者所以就不看; 4.是的,你需要一台Mac,如果你真的打算好好学Objective-C和Cocoa的话; 5.不要放过任何一个看上去很简单的小编程问题——他们往往并不那么简单,或者可以引伸出很多知识点; 6.会用Objective-C,并不说明你会Cocoa编程; 7.学语法并不阅读全文

posted @ 2011-01-28 18:53 乔乔lovefreedom 阅读(211) 评论(0) 编辑

2011年1月27日 #

dotNET反射技术总结-感谢前人的指引

摘要: 反射技术反射(Reflection)是.NET中的重要机制,通过放射,可以在运行时获得.NET中每一个类型(包括类、结构、委托、接口和枚举等)的成员,包括方法、属性、事件,以及构造函数等。还可以获得每个成员的名称、限定符和参数等。有了反射,即可对每一个类型了如指掌。如果获得了构造函数的信息,即可直接创建对象,即使这个对象的类型在编译时还不知道。   1、.NET可执行应用程序结构   程序代码在编译后生成可执行的应用,我们首先要了解这种可执行应用程序的结构。   应用程序结构分为应用程序域—程序集—模块—类型—成员几个层次,公共语言运行库加载器管理应用程序域,这种管理包括将每个程序集加载到相应阅读全文

posted @ 2011-01-27 13:58 乔乔lovefreedom 阅读(73) 评论(0) 编辑

仅列出标题  下一页