Samples coming with SDK are intended to provide best practices. So logically it looks perfectly valid to take code from them. But usually samples come under licenses, for example a lot of samples from Microsoft are released under Microsoft Public License (MS-PL).
Samples are usually published to provide best practices and common reusable code. But how can I use code from samples if they are under rather strict licenses?