Benedict Cumberbatch has hinted that he may have had a gay encounter while studying at an all-boys boarding school.

Speaking in the November issue of Out Magazine, the Sherlock actor drew on his own personal experiences to condemn anti-gay prejudice.

Recalling his time at Brambletye School in West Sussex, he told the popular gay and lesbian lifestyle magazine that there had been some sexual experimentation but insists it "wasn't out of desire."

"While there was experimentation [at Brambletye], it had never occurred to me as 'Oh, this is that,'" he said.

"It was just boys and their penises, the same way with girls and vaginas and boobs. It wasn't out of desire."

The 38-year-old British actor went on to insist that although Hollywood has come far over the last 40 years, leading men still felt an element of fear about coming out of the closet.

In upcoming drama The Imitation Game, Cumberbatch takes on the role of gay code breaker Alan Turing, who despite helping to break the Enigma Code used by the Nazis during World War II, was later prosecuted for "engaging in homosexual relations".

"I think if you're going to sell yourself as a leading man in Hollywood to say 'I'm gay,' sadly, is still a huge obstacle. We all know actors who are [gay] who don't want to talk about it or bring it up, or who deny it. I don't really know what they do to deal with it."

For Cumberbatch, who officiated the civil ceremony of two gay friends in Ibiza in 2013, equal rights for the LGBT community is crucial to making the world a better place.

He continued: "I'd take up arms against someone who was telling me I had to believe in what they believed or they would kill me. I would fight them. I would fight them to the death.

"Human rights movements and sexual and gay rights movements have made huge social progress in the last 40 years, without a doubt, but there's a lot more work to be done.

"I think it's extraordinary that every time we get to a point where there's any kind of trouble in society, people are scapegoated very, very, very quickly," he added.