1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class Default
{
        class BankAccount
        {
        public string BankCode{get;set;}
        public string AccountNumber{get;set;}
        public string AccountType{get;set;}
            public string Amount{get;set;}
            public string Source{get;set;}
            public override bool Equals(object obj)
            {
          var acc = obj as BankAccount;
          return Equals(acc);
        }
        
        public override int GetHashCode()
        {
          return this.GetHashCode();
        }
        
        public bool Equals(BankAccount acc2)
        {
          if(acc2 == null) return false;
          if(string.IsNullOrEmpty(acc2.BankCode)) return false;
          if(string.IsNullOrEmpty(acc2.AccountNumber)) return false;
          return this.BankCode.Equals(acc2.BankCode) && this.AccountNumber.Equals(acc2.AccountNumber);
        }
    }
        
    public static void Main(string[] args)
    {
        //int i;
        List<BankAccount> lst = new List<BankAccount>();
        BankAccount acc = new BankAccount();
        acc.AccountNumber = "123";
        acc.BankCode = "456";
        acc.AccountType = "S";
        acc.Amount = "46";
        acc.Source = "lst1";
        lst.Add(acc);
        
        acc = new BankAccount();
        acc.AccountNumber = "456";
        acc.BankCode = "123";
        acc.AccountType = "S";
        acc.Amount = "64";
        acc.Source = "lst1";
        lst.Add(acc);
        
        Console.WriteLine("==List 1==");
        foreach(var item in lst)
        {
          Console.WriteLine("BankCode={0}\nAccountNumber={1}\nAccountType={2}\nAmount={3}\nSource={4}\n",
                item.BankCode,
                item.AccountNumber,
                item.AccountType,
                item.Amount,
                item.Source);
        }
        List<BankAccount> lst1 = new List<BankAccount>();
        acc = new BankAccount();
        acc.AccountNumber = "123";
        acc.BankCode = "456";
        acc.AccountType = "P";
        acc.Amount = "78";
        acc.Source = "lst2";
        lst1.Add(acc);
        
        acc = new BankAccount();
        acc.AccountNumber = "1456";
        acc.BankCode = "1232";
        acc.AccountType = "S";
        acc.Amount = "100";
        acc.Source = "lst2";
        lst1.Add(acc);
        
        Console.WriteLine("==List 2==");
        foreach(var item in lst1)
        {
          Console.WriteLine("BankCode={0}\nAccountNumber={1}\nAccountType={2}\nAmount={3}\nSource={4}\n",
                item.BankCode,
                item.AccountNumber,
                item.AccountType,
                item.Amount,
                item.Source);
        }
        
        //List<BankAccount> lst3 = lst.Union(lst1).ToList();
        
        Console.WriteLine("==List 3==");
        /*
        foreach(var item in lst3)
        {
          Console.WriteLine("BankCode={0}\nAccountNumber={1}\nAccountType={2}\nAmount={3}\nSource={4}",
                item.BankCode,
                item.AccountNumber,
                item.AccountType,
                item.Amount,
                item.Source);
        }
        */
    }
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//  Microsoft (R) .NET Framework IL Disassembler.  Version 4.0.30319.1
//  Copyright (c) Microsoft Corporation.  All rights reserved.



// Metadata version: v4.0.30319
.assembly extern mscorlib
{
  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )                         // .z\V.4..
  .ver 4:0:0:0
}
.assembly Gobiner.CSharpPad.Eval.Evil1530555646
{
  .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) 
  .custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78   // ....T..WrapNonEx
                                                                                                             63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 )       // ceptionThrows.
  .hash algorithm 0x00008004
  .ver 0:0:0:0
}
.module Gobiner.CSharpPad.Eval.Evil1530555646.exe
// MVID: {FDE2EB2B-5F9E-4D98-A6A9-79DE99BFA958}
.imagebase 0x00400000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003       // WINDOWS_CUI
.corflags 0x00000001    //  ILONLY
// Image base: 0x00000000009D0000


// =============== CLASS MEMBERS DECLARATION ===================

.class public auto ansi beforefieldinit Default
       extends [mscorlib]System.Object
{
  .class auto ansi nested private beforefieldinit BankAccount
         extends [mscorlib]System.Object
  {
    .field private string '<BankCode>k__BackingField'
    .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) 
    .field private string '<AccountNumber>k__BackingField'
    .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) 
    .field private string '<AccountType>k__BackingField'
    .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) 
    .field private string '<Amount>k__BackingField'
    .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) 
    .field private string '<Source>k__BackingField'
    .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) 
    .method public hidebysig specialname 
            instance string  get_BankCode() cil managed
    {
      .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) 
      // 
      .maxstack  8
      IL_0000:  ldarg.0
      IL_0001:  ldfld      string Default/BankAccount::'<BankCode>k__BackingField'
      IL_0006:  ret
    } // end of method BankAccount::get_BankCode

    .method public hidebysig specialname 
            instance void  set_BankCode(string 'value') cil managed
    {
      .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) 
      // 
      .maxstack  8
      IL_0000:  ldarg.0
      IL_0001:  ldarg.1
      IL_0002:  stfld      string Default/BankAccount::'<BankCode>k__BackingField'
      IL_0007:  ret
    } // end of method BankAccount::set_BankCode

    .method public hidebysig specialname 
            instance string  get_AccountNumber() cil managed
    {
      .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) 
      // 
      .maxstack  8
      IL_0000:  ldarg.0
      IL_0001:  ldfld      string Default/BankAccount::'<AccountNumber>k__BackingField'
      IL_0006:  ret
    } // end of method BankAccount::get_AccountNumber

    .method public hidebysig specialname 
            instance void  set_AccountNumber(string 'value') cil managed
    {
      .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) 
      // 
      .maxstack  8
      IL_0000:  ldarg.0
      IL_0001:  ldarg.1
      IL_0002:  stfld      string Default/BankAccount::'<AccountNumber>k__BackingField'
   
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
==List 1==
BankCode=456
AccountNumber=123
AccountType=S
Amount=46
Source=lst1

BankCode=123
AccountNumber=456
AccountType=S
Amount=64
Source=lst1

==List 2==
BankCode=456
AccountNumber=123
AccountType=P
Amount=78
Source=lst2

BankCode=1232
AccountNumber=1456
AccountType=S
Amount=100
Source=lst2

==List 3==