Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace lab_6_z_12_csharp
- {
- interface Ix
- {
- string F0(int n);
- void F1(int n2);
- }
- interface Iy
- {
- void F0(int n, out string s);
- void F1(int n2);
- }
- public class Cl1 : Ix, Iy
- {
- public string str1;
- public Cl1() { }
- public Cl1(string st)
- {
- this.str1 = st;
- }
- public string F0(int n)
- {
- //Console.WriteLine("From class 1, interface Ix");
- string s = this.str1;
- char ch = s[n];
- string s2 = Convert.ToString(ch);
- s = s.Replace(s2, "+");
- return s;
- }
- void Ix.F1(int n2)
- {
- Console.WriteLine("From class 1, interface Ix");
- char ch = this.str1[n2];
- string s = Convert.ToString(ch);
- this.str1 = this.str1.Replace(s, "+");
- }
- public void F0(int n, out string s)
- {
- s = this.str1;
- char ch = s[n];
- string s2 = Convert.ToString(ch);
- s = s.Replace(s2, "+");
- }
- void Iy.F1(int n)
- {
- Console.WriteLine("From class 1, interface Iy");
- char ch = this.str1[n];
- string s = Convert.ToString(ch);
- this.str1=this.str1.Replace(s, "+");
- }
- }
- class Cl2 : Ix, Iy
- {
- public string str2;
- public Cl2() { }
- public Cl2(string st)
- {
- this.str2 = st;
- }
- public string F0(int n)
- {
- //Console.WriteLine("From class 2, interface Ix");
- string s1 = string.Copy(str2);
- s1 = s1.Substring(n);
- return s1;
- }
- public void F1(int n2)
- {
- //Console.WriteLine("From class 2, interface ???");
- this.str2 = this.str2.Substring(n2);
- }
- public void F0(int n, out string s)
- {
- s = this.str2;
- //Console.WriteLine("From class 2, interface Iy");
- s = s.Substring(n);
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Cl1 x1 = new Cl1("abcdef");
- (x1 as Ix).F1(2);
- Console.WriteLine(x1.str1);
- Cl1 x12 = new Cl1("abcdef");
- (x12 as Iy).F1(2);
- Console.WriteLine(x12.str1);
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement