摘要:
OracleDBConsole 无法启动 阅读全文
随笔档案-2013年04月
面试题目
2013-04-08 15:25 by Yang-Onion, 179 阅读, 收藏,
摘要:
记录一下在面试过程中碰到的一些面试题目,以供查缺补漏。1:typeof()和GetType()的区别 同:它们都返回System.Type类型 异:typeof(x),只是一个运算符,只能针对类型进行运算。即x,只能为类型,不能是一个类型变量。 x.GetType(),继承自Object的方法,任何一个object变量都可以使用。typeof和GetType的区别Person p = new Person();//正确typeof(Person);//错误typeof(p);//正确p.GetType();//错误,继承自Object的GetType()是一个实例方法,需要实例化一个对象... 阅读全文
go中的并发(goroutine)
2013-04-04 23:19 by Yang-Onion, 642 阅读, 收藏,
摘要:
package mainimport ( "fmt" "runtime")func main() { //goroutine 其实就是线程,但它比线程小,执行goroutine时只需较少的栈内存(4~5KB) //c#中新建一个thread要分配1M的内存栈。所以,goroutine可以同时运行比较多的并发任务 //goroutine也正是因为这个原因比thread更易用、更高效、更轻便 //goroutine 通过关键字go实现,go funcName(参数) //示例 //go sayHello("anther--Hello") 阅读全文
Golang中的面向对象
2013-04-04 23:18 by Yang-Onion, 656 阅读, 收藏,
摘要:
package mainimport ( "fmt" "math")func main() { //method:method的概念,method是附属在一个给定的类型上的, //他的语法和函数的声明语法几乎一样,只是在func后面增加了一个receiver(也就是method所依从的主体)。 //method的语法如下: //func(r ReceiverType) funcName(parameters)(results) //虽然method的名字一模一样,但是如果接收者不一样,那么method就不一样 //method里面可以访问接收者的字段 / 阅读全文
Golang中的interface
2013-04-04 23:17 by Yang-Onion, 6006 阅读, 收藏,
摘要:
package mainimport ( "fmt" "reflect" "strconv")func main() { //interface类型 //interface类型定义了一组方法,如果某个对象实现了某个接口的"所有方法",则此对象就实现了此接口 //interface可以被任意的对象实现,一个对象可以实现任意多个interface //任意的类型都实现了空interface(我们这样定义:interface{}),也就是包含0个method的interface。 //interface的值 /* mik 阅读全文
Golang中的struct
2013-04-04 23:16 by Yang-Onion, 393 阅读, 收藏,
摘要:
package mainimport ( "fmt")func main() { var tom Person tom.name = "Tom" tom.age = 26 fmt.Printf("my name is %s,I'm %d years old\n", tom.name, tom.age) //按顺序赋值 jim := Person{"Jim", 25} fmt.Printf("my name is %s,I'm %d years old\n", jim.name, 阅读全文
Golang流程语句
2013-04-04 23:15 by Yang-Onion, 857 阅读, 收藏,
摘要:
package mainimport ( "fmt")func main() { //if /* x := 5 if x > 10 { fmt.Println("X is larger than 10") } else { fmt.Println("X is smaller than 10") } //也可写成 //if y := GetSomeNumber(); y < 10 { //} */ //goto 用goto跳转... 阅读全文
Golang基本数据类型
2013-04-04 23:14 by Yang-Onion, 460 阅读, 收藏,
摘要:
package mainimport ( "fmt")func main() { var tom Person tom.name = "Tom" tom.age = 26 fmt.Printf("my name is %s,I'm %d years old\n", tom.name, tom.age) //按顺序赋值 jim := Person{"Jim", 25} fmt.Printf("my name is %s,I'm %d years old\n", jim.name, 阅读全文
浙公网安备 33010602011771号