Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Edit] C# Classes: Static Definition #5460 #5462

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

Russellzj
Copy link

Description

Added an expanded description of C# static class. Also, included examples for using and creating static classes.

Issue Solved

Issue: [Edit] C# Classes #5429

Type of Change

  • Editing an existing entry (fixing a typo, bug, issues, etc)
  • Added additional information

Checklist

  • All writings are my own.
  • My entry follows the Codecademy Docs style guide.
  • My changes generate no new warnings.
  • I have performed a self-review of my own writing and code.
  • I have checked my entry and corrected any misspellings.
  • I have made corresponding changes to the documentation if needed.
  • I have confirmed my changes are not being pushed from my forked main branch.
  • I have confirmed that I'm pushing from a new branch named after the changes I'm making.
  • I have linked any issues that are relevant to this PR in the Issues Solved section.

@SaviDahegaonkar SaviDahegaonkar self-assigned this Oct 13, 2024
@SaviDahegaonkar SaviDahegaonkar added enhancement New feature or request hacktoberfest c# C# entries status: under review Issue or PR is currently being reviewed labels Oct 14, 2024
Copy link
Collaborator

@SaviDahegaonkar SaviDahegaonkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Russellzj ,
LGTM! This entry looks good for Second round of review.

Thanks,
Savi

### Example
<<<<<<< HEAD
In the example below, a static class called `MyStaticClass` is created. The commented out code shows what you can't do with static classes. If these commented out pieces of code were to be uncommented the code would not compile. Take note on how we create fields and methods in the class and how we use our static class in other classes.
=======
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
=======

In the example below, a static class called `MyStaticClass` is created. The commented out code shows what you can't do with static classes. If these commented out pieces of code were to be uncommented the code would not compile. Take note on how we create fields and methods in the class and how we use our static class in other classes.
=======
In the example below, a static class called `MyStaticClass` is created. The commented out code shows what you can not do with static classes. If these commented out pieces of code were to be uncommented the code would not compile. Take note on how we create properties and methods in the class and how we use it in the `CallingClass` class.
>>>>>>> ffb4726d (Example for static classes added)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
>>>>>>> ffb4726d (Example for static classes added)

Remove this line.

Comment on lines 103 to 129
using System;

public class Main
{
public static void Main()
{
//The following will produce a compile time error
//MyStaticClass NonStaticError = new MyStaticClass():

//
int DoubleFive = MyStaticClass.GetDouble(5);
Console.WriteLine(DoubleFive);
}
}

public static class MyStaticClass
{
//The folowing will produce a compile time error
//public int NonStaticField = 5;

public static int StaticField = 10;

//Returns double of the value given
public static int GetDouble(int value) {
return value * 2;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
using System;
public class Main
{
public static void Main()
{
//The following will produce a compile time error
//MyStaticClass NonStaticError = new MyStaticClass():
//
int DoubleFive = MyStaticClass.GetDouble(5);
Console.WriteLine(DoubleFive);
}
}
public static class MyStaticClass
{
//The folowing will produce a compile time error
//public int NonStaticField = 5;
public static int StaticField = 10;
//Returns double of the value given
public static int GetDouble(int value) {
return value * 2;
}
}
using System;
public class Program
{
public static void Main()
{
//The following will produce a compile-time error
//MyStaticClass NonStaticError = new MyStaticClass();
//
int DoubleFive = MyStaticClass.GetDouble(5);
Console.WriteLine(DoubleFive);
}
}
public static class MyStaticClass
{
//The following will produce a compile -time error
//public int NonStaticField = 5;
public static int StaticField = 10;
//Returns double of the value given
public static int GetDouble(int value) {
return value * 2;
}
}

@SaviDahegaonkar SaviDahegaonkar added status: review 1️⃣ completed hacktoberfest-accepted Indicates the PR was approved, merged, and pertains to Hacktoberfest status: ready for next review and removed hacktoberfest status: under review Issue or PR is currently being reviewed labels Oct 14, 2024
@dakshdeepHERE dakshdeepHERE self-assigned this Oct 18, 2024
@dakshdeepHERE dakshdeepHERE added status: under review Issue or PR is currently being reviewed and removed status: ready for next review labels Oct 18, 2024
@dakshdeepHERE
Copy link
Collaborator

@Russellzj please commit the changes made by @SaviDahegaonkar before we can move to second review.

@Russellzj
Copy link
Author

@Russellzj please commit the changes made by @SaviDahegaonkar before we can move to second review.

Just committed the changes that were requested!

@Sriparno08 Sriparno08 self-assigned this Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c# C# entries enhancement New feature or request hacktoberfest-accepted Indicates the PR was approved, merged, and pertains to Hacktoberfest status: review 1️⃣ completed status: under review Issue or PR is currently being reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants