Skip to content

Instantly share code, notes, and snippets.

View cz75hiro's full-sized avatar

cz75hiro cz75hiro

  • Personal
  • Fukuoka, Japan
View GitHub Profile
/// <summary>
/// 抽象再帰クラス
/// </summary>
public abstract class RecursionBase<T> where T : RecursionBase<T> {
#region コンストラクタ
protected RecursionBase() {
Children = new RecursionCollection(this);
}
public class testClass : RecursionBase<testClass> {
public testClass() {
this.Name = "oya";
//Addしてみる
this.Children.Add(new testClass() { Name = "ko1" });
this.Children[0].Children.Add(new testClass() { Name = "mago1" });
//AddRangeしてみる
var children = new RecursionCollection(this);
children.Add(new testClass() { Name = "ko2" });
children.Add(new testClass() { Name = "ko3" });
/// <summary>
///Within のテスト
///</summary>
public void WithinTest2Helper<T>(StructInterval<T> target, T obj, bool expected) where T : struct, IComparable<T> {
bool actual = target.Within(obj);
Assert.AreEqual(expected, actual);
}
[TestMethod()]
public void WithinTest2() {
class Program
{
[STAThread]
static void Main(string[] args)
{
TestFlag f = TestFlag.b | TestFlag.d; //bとdにフラグを立てる
Console.WriteLine("{0}", f.HasFlag(TestFlag.a));
Console.WriteLine("{0}", f.HasFlag(TestFlag.b));
Console.WriteLine("{0}", f.HasFlag(TestFlag.c));
interface IData //データインターフェース
{
}
public abstract class SchemaBase//DBスキーマ抽象クラス
{
public SchemaBase() { }
}
public abstract class DAOBase<TSchema, TData>//DAOパターン抽象クラス
@cz75hiro
cz75hiro / gist:593478
Created September 23, 2010 11:08
Genericの間違えた使い方
interface IData //データインターフェース
{
}
public abstract class SchemaBase//DBスキーマ抽象クラス
{
public SchemaBase() { }
}
public abstract class DAOBase<TSchema, TData>//DAOパターン抽象クラス
@cz75hiro
cz75hiro / gist:722954
Created December 1, 2010 04:34
参照型のパラメータの渡し方の違い
class Program{
static void Main(string[] args){
//参照型の値渡し
TestClass t1 = new TestClass();
TestClass t2 = ValMethod(t1);
Console.WriteLine(t1 == t2);//false
//参照型の参照渡し
TestClass t3 = new TestClass();
@cz75hiro
cz75hiro / gist:735906
Created December 10, 2010 07:25
Enumに柔軟な拡張を追加する試み
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
namespace Enumに柔軟な拡張を追加する試み {
class Program {
enum tesyEnum {
[Obsolete]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Linqメソッドで遊ぶ
{
class Program
{
static void Main(string[] args)
@cz75hiro
cz75hiro / IEnumerable<>.Union
Created January 20, 2011 10:12
Linqメソッドで遊ぶ 例外
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Linqメソッドで遊ぶ
{
class Program
{
static void Main(string[] args)