工作时间长了总是用同样的一些东西  其他的有些生疏  闲来看看面试题练习一下:  题目出处嘛...aspnet-tests-for-juniors

转载请注明来源:http://www.cnblogs.com/zaiyuzhong/p/answer-for-aspnet-test.html

1. 定义接口IQuestion:

interface IQuestion

{

  string Title{get;set;}

  QuestionType Type{get;}

  string GetAnswer();

}

小结: interface默认为internal, 可加上public, 只有这两种访问修饰符; 成员不能声明访问修饰符 全是public; 只包含方法、属性、事件或索引器的签名(其实全是方法);

2. 定义抽象类QuestionBase:

internal abstract class QuestionBase:IQuestion

{

  public string Title{get;set;}

  public abstract QuestionType Type{get;}

  public virtual string GetAnswer()

  {

    return "默认答案";

  }

}

小结: 有默认实现的方法是虚方法, 通过 virtual 声明, 子类可重写可不重写;

3. 定义TextQuestion,MultipleChoiceQuestion类:

internal class TextQuestion:QuestionBase

{

  public override QuestionType Type{get{return QuestionType.Text}}

  public override GetAnswer()

  {

    return "文本答案";

  }

}

MultipleChoiceQuestion 只有值不一样, 略

小结: 题目没提示, 很可能忘记override Type属性;

4. 完成扩展方法 WhereNotDeleted:

public static class Tools

{

  public static IEnumerable<Product> WhereNotDeleted(this IEnumerable<Product> sender)

  {

    return sender.Where(it => it.IsDeleted == "false");

  }

}

小结: 扩展方法是静态类的静态方法, 第一个参数this修饰;
    我有一些疑问: 1, Product的IsDeleted用bool类型比string要好;
    2, 不清楚这道题要考声明扩展方法还是筛选WhereNotDeleted, 如果是后者, 像我这样的答案应该是不行的;

5. 写出Sql语句: (SQL语句关键字全大写是个人习惯)

SELECT [Name],[Year],[Month],SUM([Amount]) AS Income
FROM [User] INNER JOIN [Income] ON [User].Id=[Income].UserId
GROUP BY [Name],[Year],[Mouth]

小结: 应该是考联合查询和GROUP BY, 测了一下四种联合查询都可以(主外键的值都对应的上,可能提问会问到区别), 测试环境SQL Server 2014;

  这里有个坑 User(表名和内置函数User()冲突, 加[]表示xx), 开始写了一个简单的select怎么都报错, 以为自己多年不用SQL忘光了, 大囧;

6. Linq语句得到5结果:

var r = from u in users
    join i in incomes on u.Id equals i.UserId
    group i by new {u.Name, i.Year, i.Mouth} into temp
    select new UserIncomeDto() {
      Name = temp.Key.Name,
      Year = temp.Key.Year,
      Month = temp.Key.Month,
      Income = temp.Sum(it => it.Amount)
    };
return r.ToList();

小结: 熟悉Linq...

7. 修改HTML和路由:

HTML:  <form action="..." method="post">

    <input name="username" type="text" placeholder="username" />

    <input name="password" type="password" placeholder="password" />

Routes: routes.MapRoute(

      name: "MobileLogin"

      url: "/admin/mobile/user/login",

      defaults: new { controller = "User", action = "Login"}

      ); //注意路由顺序

小结: form 可能会忘记声明method, 我不记得form默认是post还是get了, 还是声明一下的好;

8. 完成Require方法:

private void Require(Func<Product,string> selector, string msg)

{

  var value = selector.Invoke(this);

  if(string.IsNullOrEmpty(value)) throw new Exception(msg);

}

小结: 这题好, 以前没注意过还可以这么造...

如果是笔试, 这道题还是不错的, 有难度有区分, 中级开发者不借助VS不一定能写出来, 在后续的提问环节可以更好的了解应聘者的技术能力

#region 2015-01-04 补充
9. 现有蓝色底的纸板... :

private void FillGround(Block ground, IEnumerable list)

{

  //思路有点问题, 我先保存一下

  // 不行  这道题到我极限了.. 要研究一段时间了

}

#endregion

一些Asp.Net面试题答案的更多相关文章

  1. 关于完整解答Leo C.W博客中名为“我们公司的ASP.NET 笔试题,你觉得难度如何”的所有题目

    关于完整解答Leo C.W博客中名为“我们公司的ASP.NET 笔试题,你觉得难度如何”的所有题目,请大家鉴定,不足之处,敬请指教! 第1到3题解答如下: public enum QuestionTy ...

  2. (转)130道ASP.NET面试题

    130道ASP.NET面试题 转自http://blog.csdn.net/kingmax54212008/article/details/2021204 1. 简述 private. protect ...

  3. 远光软件ASP.NET笔试题小汇总

    ASP.NET笔试题是ASP.NET程序员面试必须经历的,一般会叫你填两个表 1个是你的详细信息表 1个是面试题答卷 两个都要注意反正面是否都有内容不要遗漏,如果考你机试一般也有两种,就是程序连接数据 ...

  4. N++ 道ASP.NET面试题

    InterviewQuestions-ASP.NET N++ 道ASP.NET面试题 1. 简述 private. protected. public. internal 修饰符的访问权限. 答 . ...

  5. ASP.NET面试题130道

     130道ASP.NET面试题 1. 简述 private. protected. public. internal 修饰符的访问权限. 答 . private : 私有成员, 在类的内部才可以访问. ...

  6. JQuery面试题答案

    jQuery面试题答案 转自:http://blog.csdn.net/zhangpei_xf/article/details/8822021 一.Jquery测试题 下面哪种不是jquery的选择器 ...

  7. Linux相关面试题&答案

    Linux相关面试题&答案 Linux面试题&答案 假设apache日志格式为:118.78.199.98 – - [09/Jan/2010:00:59:59 +0800] " ...

  8. 1+X云计算平台运维与开发(中级)eNSP A~E卷 试题+答案

    1+X云计算平台运维与开发(中级)eNSP A~E卷 试题+答案 A卷 路由器管理(40分) 41 配置R1和R2路由器(路由器使用R2220),R1路由器配置端口g0/0/1地址为192.168.1 ...

  9. asp.net 面试题(附答案)

    这次面试遇到的一些问题有很基础,也有的一些我没有听过.根据经验不同或应聘职位和公司的不同等,遇到的面试问题肯定也不一样.本人两年半asp.net开发经验,这是我年后应聘asp.net工程师遇到的问题, ...

随机推荐

  1. SQL case

    case when Value='1' then 'True'  else 'False' end as 'Result'

  2. Web开发技术发展历史

    Web开发技术发展历史   来自:天码营 原文:http://www.tianmaying.com/tutorial/web-history Web的诞生 提到Web,不得不提一个词就是"互 ...

  3. vim 支持C++11 lambda表达式

    http://www.vim.org/scripts/script.php?script_id=3797 Tar contains just the required .vim files, so u ...

  4. PHP ajax基础

    后台对数据处理,并返回前台: <?php //接收 $action = $_GET['action']; if ($action == 'orderID') { $orderID = trim( ...

  5. 大熊君大话NodeJS之------(Url,QueryString,Path)模块

    一,开篇分析 这篇文章把这三个模块拿来一起说,原因是它们各自的篇幅都不是很长,其次是它们之间存在着依赖关系,所以依次介绍并且实例分析.废话不多说了,请看下面文档: (1),"Url模块&qu ...

  6. NoClassDefFoundError vs ClassNotFoundException

    我们先来认识一下Error 和Exception, 两个都是Throwable类的直接子类.  Javadoc 很好的说明了Error类: An Error is a subclass of Thro ...

  7. cf723b Text Document Analysis

    Modern text editors usually show some information regarding the document being edited. For example, ...

  8. QString 和std::string互转

    std::string cstr; QString qstring; //****从std::string 到QString qstring = QString(QString::fromLocal8 ...

  9. iPad版微信终于来临了 微信5.4版搜索更智能 转账就是发消息

    等待甚久的iPad版微信终于来临了!昨日微信iOS版本更新至5.4.0.16,新增功能包括搜索公众号.识别图中二维码.面对面收钱,同时适配iPad.(微信5.4安卓版重回ios风格 导航菜单都放底栏位 ...

  10. ODBC API简介

    1.      数据类型: 通过SQLGetTypeInfo函数来获取ODBC 3.0支持的数据类型信息.由SQLGetTypeInfo返回的数据类型是数据源所支持的数据类型. SQLRETURN S ...