Search code examples
bloggerblogspot

Effective blog Writing


whenever I copy the contents of Visual Studio 2010 to my blog, it appears as a normal black font, with the formatting and color of the C# code not applying to my Google blogger. How do I fix this problem?

Here's an example of my code:

using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace BookStore.Models
{
    public class Book
    {
        [Key]
        public int Id { get; set; }
        [Required]
        [MaxLength(30)]
        public string Title { get; set; }
        public string Authers { get; set; }

        [Column("Year")]
        [Display(Name = "Publish Year")]
        public string publishYear { get; set; }

        [Column("Price")]
        [Display(Name = "Price")]
        public decimal BasePrice { get; set; }
    }
} 

I want this to be highlighted as C# code.


Solution

  • I have tried the following with another platform but not with Blogger. I am not sure whether it will serve your purpose. But it is definitely worth a try:

    1. Copy and paste from Visual Studio into a Word document.
    2. Copy and paste from the Word document into the rich text editing field of the blog.

    Copy and paste directly from Visual Studio into the rich text editing field will not preserve the syntax highlighting. I have no clue why.