Scarlett72
asked on
Type or namespace definition, or end-of-file expected error on class create
Hi, I am trying to create a class; however, when I add the code for the GetFirstDayOfNextMonth method I receive an error on the last curly brace, it looks like all my braces match and not sure why I am getting this error.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
public class CalendarClass
{
public CalendarClass()
{
protected DateTime GetFirstDayOfNextMonth(int setYear, int setMonth)
{
DateTime lastDate = new DateTime(setYear, setMonth, 1);
return lastDate;
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
To avoid confusion, I wouldn't call a constructor a method : )
ASKER
Ah, ok thank you kaufmed ... as you can probably tell, this is my first attempt a creating a class, so your attention is truly appreciated. I posted my comment without seeing yours first. So now I have moved the outside of the constructor, and now I want to use the method GetFirstDayOfNextMonth in by code behind. I can write successfully:
but that doesn't do anything, shouldn't I be able to call the method as:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
public class calClass
{
public calClass()
{
}
public DateTime GetFirstDayofCurrentMonth()
{
DateTime firstDate = new DateTime(2014, 1, 1);
return firstDate;
}
}
calClass cc = new calClass();
but that doesn't do anything, shouldn't I be able to call the method as:
cc.GetFirstDayofCurrentMonth()
ASKER
Ok, it is working now. Still trying to understand how everything flows, thank you kaufmed!
ASKER
...and fernando!
ASKER