0% found this document useful (0 votes)
23 views1 page

Using Using Using Using Using Using Using Namespace Public Partial Class Public

This document contains code for a Windows Forms application that rolls two dice and displays all possible combinations. It defines a Form1 class with a button click event that creates an instance of a Class1 object and calls its combination method. The combination method populates a string array with all possible dice roll outcomes from 1 to 6 for each die, and Form1 then adds these combinations to a list box when the button is clicked.

Uploaded by

400b
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views1 page

Using Using Using Using Using Using Using Namespace Public Partial Class Public

This document contains code for a Windows Forms application that rolls two dice and displays all possible combinations. It defines a Form1 class with a button click event that creates an instance of a Class1 object and calls its combination method. The combination method populates a string array with all possible dice roll outcomes from 1 to 6 for each die, and Form1 then adds these combinations to a list box when the button is clicked.

Uploaded by

400b
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Q2.Rolling_dice
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Class1 obj = new Class1();
private void button1_Click(object sender, EventArgs e)
{
obj.combination();
for (int a = 0; a < 36; a++)
{
listBox1.Items.Add( obj.combinations[a]);
}
}
}

using System;
using System.Collections.Generic;
using System.Text;

namespace Q2.Rolling_dice
{
class Class1
{
public string[] combinations = new string[36];
protected int index;
public void combination()
{
for (int a = 1; a <= 6; a++)
{
for (int b = 1; b <= 6; b++)
{
combinations[index] = a.ToString() + " " + b.ToString();
index++;
}
}
}
}
}

You might also like