error saying system.void cannot be used from c#

I have a interface

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Guestbook.Models;

namespace Guestbook.Controllers
{
    public interface IGuestbookRepository
    {
        IList<GuestbookEntry> GetMostRecentEntries();
        GuestbookEntry FindById(int id);
        IList<CommentSummary> GetCommentSummary();
        Void AddEntry(GuestbookEntry entry);
    }
}

and the implementation class looks like this

using System;
using System.Collections.Generic;
using System.Linq;
using Guestbook.Models;

namespace Guestbook.Controllers
{
public class GuestbookRepository : IGuestbookRepository
{
    private readonly GuestbookContext _db = new GuestbookContext();

     public void AddEntry(GuestbookEntry entry)
     {
        entry.DateAdded = DateTime.Now;

        _db.Entries.Add(entry);
        _db.SaveChanges();
     }
}

when i type to compile it i get error saying System.void cannot be used from c# -- use typeof(void) to get the void type object.

What exactly is wrong that I'm doing? Can someone help me maybe?

Answers


This is the problem, in the interface declaration:

Void AddEntry(GuestbookEntry entry);

It should be:

void AddEntry(GuestbookEntry entry);

The first version refers to the System.Void type, which can't be used within C# (as per the error message). The second is the C# way of writing a method which no return value.


Need Your Help

Summarising dataframe based on string values

r string data.frame dplyr plyr

I want to summarise a dataframe based on the unique values of a string variable.

Confused on Excel DATEDIF “YD” Option

excel excel-formula

I am having trouble understanding the below results: