Chunchunmaru
Eternal Poster
- Joined
- Aug 31, 2021
- Posts
- 766
- Reaction
- 288
- Points
- 459
Nababaliw na ko, pano ba tawagin yung delegate class sa main method?
Eto yung codes:
Code nung windows form
Mali ba yung pag ka code ko sa delegate? Ito yung sinusunod ko
Eto yung nang yayari
Di ko sure kung saan ako mali, pero feel ko dun sa delegate, naninibago kase ako kase bagong topic to
Eto yung codes:
C#:
//Code nung delegate class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Account_Registration
{
public delegate long DelegateNumber(long number);
public delegate string DelegateText(string txt);
class StudentInfoClass
{
static string FirstName = " ", LastName = " ", MiddleName = " ", Address = " ", Program = " ";
static long Age = 0, ContactNo = 0, StudentNo = 0;
public static string GetFirstName(string FirstName)
{
return FirstName;
}
public static string GetLastName(string LastName)
{
return LastName;
}
public static string GetMiddleName(string MiddleName)
{
return MiddleName;
}
public static string GetAddress(string Address)
{
return Address;
}
public static string GetProgram(string Program)
{
return Program;
}
public static long GetAge(long Age)
{
return Age;
}
public static long GetContactNo(long ContactNo)
{
return ContactNo;
}
public static long GetStudentNo(long StudentNo)
{
return StudentNo;
}
}
}
Code nung windows form
C#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Account_Registration
{
public partial class FrmRegistration : Form
{
DelegateText delegateAddition;
DelegateNumber delegateAddition;
public FrmRegistration()
{
InitializeComponent();
delegateAddition = new DelegateText(StudentInfoClass.GetProgram);
delegateAddition = new DelegateNumber(StudentInfoClass.GetAge);
}
private void NextButton_Click(object sender, EventArgs e)
{
}
}
}
Mali ba yung pag ka code ko sa delegate? Ito yung sinusunod ko
Eto yung nang yayari
Di ko sure kung saan ako mali, pero feel ko dun sa delegate, naninibago kase ako kase bagong topic to
Attachments
-
You do not have permission to view the full content of this post. Log in or register now.