Ex-mayor Mike Bloomberg tried hard not to criticize his successor during a 34-minute interview with Katie Couric — but he just couldn’t help it.

Without calling out Mayor Bill de Blasio by name, Bloomberg said it was a mistake to boycott the St. Patrick’s Day Parade for not allowing gays to march openly, saying that isn’t an effective way to change people’s minds.

De Blasio and other prominent elected officials have said that they’re not marching in Monday’s parade up Fifth Avenue.

“I think by boycotting, it doesn’t get it done. If anything, it hardens the views,” he told Couric at her new Yahoo News post. “It makes it harder for anybody to change if you force them into a corner. That’s just not the way I would do it.”

When Couric pressed Bloomberg on whether that meant he disagrees with de Blasio’s decision not to march, he wouldn’t criticize the current mayor directly.

“Bill de Blasio’s gotta make his decision, and I respect his decision — he’s the mayor,” said Bloomberg.

But he added, “Generally speaking, I think when you force people in corners, it isn’t as useful.”

Despite insisting he’s supportive of de Blasio, Bloomberg also challenged his plans to tax the wealthy and to oppose charter schools.

“Trying to tax people and having them move or companies do their business elsewhere. It sounds good, it’s great populist rhetoric — but it’s a disaster,” said Bloomberg.

He said charter schools generally provide students — mostly low-income and minority kids — with a great education. But he didn’t hesitate to call the the UFT’s low-performing East New York charter school a “disgrace.”

He also suggested the battle over space-sharing arrangements between traditional public and charter schools was misguided.

“The thing with charter schools is they’re public schools … and they act as a role model for other public schools,” said the former mayor. “Every school takes away space that somebody else could use — by definition what we’re supposed to do in school buildings is put schools,” he said of the current battles over classroom space. “I mean, it’s a nonsensical thing if you think about it.”

On homelessness, which rose to unprecedented levels under his tenure, Bloomberg insisted he wouldn’t have done anything differently.

He also repeated a much-criticized claim that part of the increase in homelessness was attributable to the more attractive shelter system his administration put in place.

“You can literally come, fly first-class to Kennedy Airport and say to the taxi driver, ‘Take me to the shelter system.’ And we have to provide shelter,” he said.

“Do you really think people do that?” asked Couric.

“There’s a handful. There’s no question there’s a handful — it’s not a lot of people,” he answered.

Now serving as the United Nations’ special envoy for cities and climate change, Bloomberg vowed to continue his national lobbying on gun control, obesity and limiting the size of sugary drinks.

As one of the world’s wealthiest people, he said it would be a “shame” if he didn’t continue his ways on philanthropic and social issues.

Asked at the end of the interview what he wanted his tombstone to read, Bloomberg answered: “I guess maybe something cute like ‘Made a difference.'”